Re: Bug in JDBC-Driver?

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: pg(at)fastcrypt(dot)com
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Kris Jurka <books(at)ejurka(dot)com>, Antje(dot)Stejskal(at)ppi(dot)de, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bug in JDBC-Driver?
Date: 2004-12-01 00:11:49
Message-ID: 41AD0C45.2090002@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nicolas Modrzyk 2004-12-01 08:31:56 Postgresql driver Question
Previous Message Dave Cramer 2004-11-30 23:17:42 Re: Bug in JDBC-Driver?