Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 4A15C9FA1DE for ; Wed, 6 Dec 2006 10:54:23 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 47645-01 for ; Wed, 6 Dec 2006 10:54:07 -0400 (AST) X-Greylist: delayed 00:07:35.305118 by SQLgrey-1.7.4 Received: from mail.gtech.kiev.ua (mail.gtech.kiev.ua [213.186.209.2]) by postgresql.org (Postfix) with ESMTP id DDC869FA430 for ; Wed, 6 Dec 2006 10:54:12 -0400 (AST) Received: from localhost ([127.0.0.1]) by mail.gtech.kiev.ua (using TLSv1/SSLv3 with cipher AES256-SHA (256 bits)) for pgsql-jdbc@postgresql.org; Wed, 6 Dec 2006 17:46:34 +0200 Message-ID: <4576D7C4.4040602@gtech-ua.com> Date: Wed, 06 Dec 2006 16:46:28 +0200 From: Vit Timchishin User-Agent: Thunderbird 1.5.0.8 (X11/20060911) MIME-Version: 1.0 CC: pgsql-jdbc@postgresql.org Subject: Re: Something wrong with binding timestamp values References: <200612061458.32156.peter_e@gmx.net> <1165415895.9734.286.camel@archimedes> In-Reply-To: <1165415895.9734.286.camel@archimedes> Content-Type: text/plain; charset=KOI8-U Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.862 tagged_above=0 required=5 tests=BAYES_50, FROM_LOCAL_NOVOWEL X-Spam-Level: ** X-Archive-Number: 200612/40 X-Sequence-Number: 16272 Mark Lewis wrote: > It's to work around the fact that JDBC only knows about one Timestamp > type, while PG knows about more. It ends up being better in most cases > to send the type as unknown and let the server disambiguate to the > correct type than to guess about the type and maybe guess wrong. > > This was a recent change, which is why it used to work for you but now > doesn't. It was known that cases like yours which call overloaded > functions may require an explicit cast, something like "SELECT > date_trunc('day', ?::timestamp)", but it was decided that it's better to > force a cast in some cases than to do things demonstrably wrong in other > cases (which the older driver versions were wont to do). > > You can dig through the archives for more of the gory details. > > Actually I am not having this problem, but I see every time people has problems with it. Would not it be helpful to create, say, PostgreTimestamp extends java.sql.Timestamp and PostgreZonedTimestamp extends java.sql.Timestamp. Then check if one uses this classes in setTimestamp/setObject and in this case use definite bindings. And even more, return one of this types from getTimestamp, so that some applications that do read/write will work better even without knowing this problem. Other application, of course, will be forced to use ::timestamp OR this new classes explicitly. But this gives more flexibility - one would may choose to change query text OR parameter creating and it may be much easier in some cases to change parameter creating then sql texts.