patch against cvs for getTimestamp() problem.

Поиск
Список
Период
Сортировка
От Thomas O'Dowd
Тема patch against cvs for getTimestamp() problem.
Дата
Msg-id 20011208144051.C17132@beast.uwillsee.com
обсуждение исходный текст
Ответы Re: (2) patch against cvs for getTimestamp() problem.  ("Thomas O'Dowd" <tom@nooper.com>)
Список 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@nooper.com - Testing - http://nooper.co.jp/labs

Вложения

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Ned Wolpert
Дата:
Сообщение: Re: Bug in org.postgresql.Connection
Следующее
От: "Thomas O'Dowd"
Дата:
Сообщение: Re: (2) patch against cvs for getTimestamp() problem.