patch against cvs for getTimestamp() problem.

From: "Thomas O'Dowd" <tom(at)nooper(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: patch against cvs for getTimestamp() problem.
Date: 2001-12-08 05:40:51
Message-ID: 20011208144051.C17132@beast.uwillsee.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi all,

I just upgraded my development environment to 7.2b3 and the latest cvs
driver both built from source. I found that ResultSet.getTimestamp()
was no longer working against a 7.2 database and causing an exception
parsing the timestamp that pg was returning.

Bad Timestamp Format at 23 in 2001-12-06 23:24:07.895882+09
at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1707)
at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:398)

It seems that timestamps have become more accurate in 7.2 going from
2 fractional second digits to 6 which was causing the exception. Looking
at the code in toTimestamp() I decided that it was better to rewrite
it, then add a small fix as the method of parsing before was error
prone in my opinion and the new code (less the comments) is smaller
and easier to read IMHO :)

I'm including patches against jdbc1 and jdbc2 ResultSet.java. I generated
the patch against the latest cvs, using cvs diff -c. I've tested the
jdbc2 versions pretty well and it parses the following combinations

"2001-12-07 16:29:22.47+09",
"2001-12-07 16:29:26+09",
"2001-12-07 16:26:50.144213+09",
"2001-12-07 16:26:59.461349+09",
"2001-12-07 16:26:59.461349+05:30",
"2001-12-07 00:00:00+09",
"2001-12-07 12:00:00",
"2001-12-07"

The driver is set to return ISO datestyle formats so I'm not sure if the
latter two formats are required but as the older code supported them, I've
added code to do this. If anyone can suggest more formats that pg may
return I can test those on the new code too. I've been running the new
driver with my code with no problem now.

If anyone has any questions or suggestions please let me know. I think
this is an important bug fix for the 7.2 release of pg. Can someone test
the changes in the jdbc1 driver as I don't have a means of doing this.

The patch file is attached.

Regards,

Tom.
--
Thomas O'Dowd. - Nooping - http://nooper.com
tom(at)nooper(dot)com - Testing - http://nooper.co.jp/labs

Attachment Content-Type Size
rs_patch text/plain 15.1 KB

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas O'Dowd 2001-12-08 09:55:32 Re: (2) patch against cvs for getTimestamp() problem.
Previous Message Ned Wolpert 2001-12-07 23:05:53 Re: Bug in org.postgresql.Connection