X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 928A6D8662 for ; Thu, 8 Sep 2005 08:26:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65153-01 for ; Thu, 8 Sep 2005 11:26:18 +0000 (GMT) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.205]) by svr1.postgresql.org (Postfix) with ESMTP id 55345D8634 for ; Thu, 8 Sep 2005 08:26:19 -0300 (ADT) Received: by xproxy.gmail.com with SMTP id i27so971749wxd for ; Thu, 08 Sep 2005 04:26:23 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=H3gKAUjA9efXX3lvdf1EqEvFgHrmKdtz0DGuojLFywUeAlguglqP8cExhR+e+fXV58e4K9l9zQTiOs8dqJQXJDh223lRaL6zDXpOYO36SgTZMsWkm0XvPE/19kVkjuFmQV4l36GiRJwkyrQl6f1MHATW0RSoxP3Ba/bW5usFOR4= Received: by 10.70.13.4 with SMTP id 4mr40139wxm; Thu, 08 Sep 2005 04:26:23 -0700 (PDT) Received: by 10.70.35.4 with HTTP; Thu, 8 Sep 2005 04:26:23 -0700 (PDT) Message-ID: <5a59b8db0509080426438d4370@mail.gmail.com> Date: Thu, 8 Sep 2005 14:26:23 +0300 From: Gil G To: pgsql-jdbc@postgresql.org Subject: TimestampUtils.loadCalendar failes for interval type Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_4648_14378902.1126178783375" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.045 required=5 tests=[FROM_ENDS_IN_NUMS=0.516, HTML_20_30=0.504, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: * X-Archive-Number: 200509/32 X-Sequence-Number: 13817 ------=_Part_4648_14378902.1126178783375 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, I've executed following query:=20 select t.date-t.date2 from table as t The query should return a single row of type interval. Indeed,=20 resultSet.getObject(1) returns a PGInterval instance with the correct value= =20 (the returned interval is 2 days and several hours). When I call resultSet.getString(1) the string representation of interval is= =20 "2 days 14:08:55.8246". The problem arises when I call resultSet.getTimestamp(1).=20 As I saw in org.postgresql.jdbc2.TimestampUtils.loadCalendar(GregorianCalen= dar=20 cal, String s, String type) it fails to parse correctly=20 the string, which is returned by resultSet.getString(1) call. since it=20 expects only the "14:08:55.8246" part and does not expect the "2 days " par= t.=20 Please note that in case the interval between two dates is smaller than 24= =20 hours everything works correctly.=20 This is important since, generic products such as Hibernate that work over= =20 different jdbc drivers, refer to the interval data type as a=20 java.sql.Timestamp object and call getTimestamp(int) method on the resultse= t=20 to get the instance. Thanks, Gil ------=_Part_4648_14378902.1126178783375 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi,

I've executed following query:
select t.date-t.date2 from table as t

The query should return a single row of type interval. Indeed, resultSet.getObject(1) returns a PGInterval instance with the correct value (the returned interval is 2 days and several hours).

When I call resultSet.getString(1) the string representation of interval is= "2 days 14:08:55.8246"= .
The problem arises when I call resultSet.getTimestamp(1).
As I saw in org.postgresql.jdbc2.TimestampUtils.loadCalendar(GregorianCalendar cal, String s, String type) it fails to parse correctly
the string, which is returned by resultSet.getString(1) call. since it expe= cts only the "14:08:55.8246" part and does not expect
the "2 days " p= art. Please note  that  in case the interval between two dates is= smaller than 24 hours everything works correctly.

This is important since, generic products such as Hibernate that work over different jdbc drivers, refer to the interval data type as a java.sql.Timestamp object and call getTimestamp(int) method  on the resultset to get the instance.

Thanks,
Gil
------=_Part_4648_14378902.1126178783375--