Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Failure in timestamptz of JDBC of 7.2b4

From: Barry Lind <barry(at)xythos(dot)com>
To: Ryouichi Matsuda <r-matuda(at)sra(dot)co(dot)jp>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [HACKERS] Failure in timestamptz of JDBC of 7.2b4
Date: 2001-12-27 02:44:35
Message-ID: 3C2A8B13.4070907@xythos.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-jdbc
Ryouichi,

I did not follow your explaination of the problem and therefore I don't 
see how your suggested patch fixes the problem.

You claim that the jdbc driver does not support the timestamptz type. 
However when I try using this type, I don't have any problems.  I just 
executed the sql statements you had included in your email:

select 'now'::timestamp;
select 'now'::timestamptz;
select 'now'::timestamp with time zone;

These all seem to work correctly for me.

Then however I did try your last query:

select 'now'::timestamp without time zone;

and this does fail for me with the string index out of bounds exception. 
  However the patch you sent does not seem to fix this error.  And I 
really don't know what to do with this datatype, since jdbc does not 
have a corresponding datatype that doesn't contain timezone information.

So to summarize, after looking at the sql statements you mention in your 
email, they all seem to work correctly for me without your patch being 
applied, except for the last one, which still fails even with your patch 
applied.  So I am unsure what your patch is supposed to fix, since I do 
not see any evidence that it fixes anything that is broken.

thanks,
--Barry



Ryouichi Matsuda wrote:

> I found a failure in a JDBC driver of 7.2b4.
>   (1) It does not support timestamptz type
>   (2) Exception occurs by timestamp without time zone type
> I attach a patch correcting the first failure.
> You can confirm it in example.psql as follows:
> 
> ---------------------------------------------------------------------
> $ java -cp postgresql-examples.jar:postgresql.jar example.psql jdbc:postgresql:r-matuda r-matuda pass
> PostgreSQL psql example v6.3 rev 1
> 
> Connecting to Database URL = jdbc:postgresql:r-matuda
> Connected to PostgreSQL 7.2b4
> 
> [1] select 'now'::timestamp;
> timestamptz
> No class found for timestamptz.
> [1] [1] select 'now'::timestamp with time zone;
> timestamptz
> No class found for timestamptz.
> [1] [1] select 'now'::timestamp without time zone;
> timestamp
> Exception caught.
> java.lang.StringIndexOutOfBoundsException: String index out of range: 26
> java.lang.StringIndexOutOfBoundsException: String index out of range: 26
>         at java.lang.String.charAt(String.java:516)
>         at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1653)
>         at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:398)
>         at org.postgresql.jdbc2.ResultSet.getObject(ResultSet.java:768)
>         at example.psql.displayResult(psql.java:137)
>         at example.psql.processLine(psql.java:96)
>         at example.psql.<init>(psql.java:62)
>         at example.psql.main(psql.java:227)
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 



In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-12-27 04:39:15
Subject: Re: Timestamp conversion can't use index
Previous:From: Bruce MomjianDate: 2001-12-27 00:32:42
Subject: Re: Smbd's bits moved somewhere far..

pgsql-jdbc by date

Next:From: Peter AdamekDate: 2001-12-27 07:16:22
Subject: Problem with connecting to postgres using JDBC with JSP, but not JDBC with Java
Previous:From: Barry LindDate: 2001-12-27 02:30:28
Subject: Re: org.postgresql.Connection#EscapeSQL and {d

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group