Re: Bug in JDBC-Driver? - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Bug in JDBC-Driver?
Date
Msg-id 41AD0C45.2090002@opencloud.com
Whole thread Raw
In response to Re: Bug in JDBC-Driver?  (Dave Cramer <pg@fastcrypt.com>)
Responses Postgresql driver Question  (Nicolas Modrzyk <Nicolas.Modrzyk@inrialpes.fr>)
List pgsql-jdbc
Dave Cramer wrote:
> Well, I'm not going to defend the spec, as it's broken in a few places.

Only a few? ;)

> However there is no setTimestamp without timezone.

java.sql.Timestamp stores UTC milliseconds-since-epoch. It also stores a
timezone offset (in minutes?!) and has YMD/HMS accessors -- but all the
timezone functionality is deprecated since JDK1.1 in favor of passing
the timestamp to an appropriate Calendar object (that has timezone info
plus locale-specific formatting logic). So it seems like Timestamp
itself is essentially "without timezone".

There is PreparedStatement.setTimestamp(column, timestamp) vs.
PreparedStatement.setTimestamp(column, timestamp, calendar). It's not
clear whether this is meant to do without-timezone vs. with-timezone,
though. The javadoc for the second variant talks about using the
provided calendar to construct a SQL DATE value, but does that mean
"store timestamp with calendar's timezone" or "convert timestamp to
local time in the given calendar and store without timezone" or
something else again? And the first variant says nothing at all about
timezones!

ResultSet has getTimestamp(column) and getTimestamp(column, calendar).
The second variant claims to do conversion of timestamp without timezone
to UTC milliseconds using the given calendar, but only for the "without
timezone" case. If you have "with timezone" the conversion to UTC just
happens automatically, and there seems to be no way to retrieve the
stored timezone information separately. Perhaps the driver is meant to
setTimezone() on the supplied calendar, but the javadoc says nothing
about this.

My head hurts..

How do other JDBC drivers handle this?

-O

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Bug in JDBC-Driver?
Next
From: Nicolas Modrzyk
Date:
Subject: Postgresql driver Question