pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: pg@fastcrypt.com
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Kris Jurka <books@ejurka.com>
Cc: Antje.Stejskal@ppi.de
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Bug in JDBC-Driver?
Date: Wed, 01 Dec 2004 13:11:49 +1300
Message-ID: <41AD0C45.2090002@opencloud.com> (raw)
In-Reply-To: <41ACFF96.6090501@fastcrypt.com>
References: <6D48B8403D926449BDE8440EC7EEC46D021F2026@max.ppinet.de>
	<Pine.BSO.4.56.0411300213500.5924@leary.csoft.net>
	<41AC5A33.8020009@fastcrypt.com>
	<Pine.BSO.4.56.0411300638040.8244@leary.csoft.net>
	<41AC65A0.4070503@fastcrypt.com>
	<21155.1101832716@sss.pgh.pa.us>
	<41ACFF96.6090501@fastcrypt.com>

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



view thread (19+ messages)  latest in thread

Message-ID: <41AD0C45.2090002@opencloud.com>
Permalink:  ../41AD0C45.2090002@opencloud.com/
Also on:    postgresql.org/message-id/41AD0C45.2090002@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, pg@fastcrypt.com, tgl@sss.pgh.pa.us, books@ejurka.com, Antje.Stejskal@ppi.de
  Subject: Re: Bug in JDBC-Driver?
  In-Reply-To: <41AD0C45.2090002@opencloud.com>
  References: <6D48B8403D926449BDE8440EC7EEC46D021F2026@max.ppinet.de> <Pine.BSO.4.56.0411300213500.5924@leary.csoft.net> <41AC5A33.8020009@fastcrypt.com> <Pine.BSO.4.56.0411300638040.8244@leary.csoft.net> <41AC65A0.4070503@fastcrypt.com> <21155.1101832716@sss.pgh.pa.us> <41ACFF96.6090501@fastcrypt.com> <41AD0C45.2090002@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox