aggregate functions and timestamps in JDBC, possible bug?

From: "Tomi Panula-Ontto" <tomi(at)panula-ont(dot)to>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: aggregate functions and timestamps in JDBC, possible bug?
Date: 2002-08-03 13:23:27
Message-ID: 000801c23af0$f43aee20$fb00a8c0@komialand
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hello,
I have a problem with PostgreSQL JDBC driver when using timestamps.

Consider this:

CREATE TABLE xyz (
starttime timestamp not null,
endtime timestamp not null
);

INSERT INTO xyz VALUES ( '2002-08-1 03:00:00+03', '2002-08-1 06:00:00+03' );
INSERT INTO xyz VALUES ( '2002-08-2 03:20:00+03', '2002-08-2 06:30:00+03' );

Then do:

SELECT SUM(endtime - starttime) FROM xyz;

And you'll get:

sum
-------
06:10
(1 row)

(Which means 6 hours and 10 minutes).

Then try to read that field using JDBC using something like:
java.sql.Timestamp ts = rs.getTimestamp(1);

And you'll get my problem:

Bad Timestamp Format at 2 in 06:10
at org.postgresql.jdbc2.ResultSet.toTimestamp(ResultSet.java:1705)
at org.postgresql.jdbc2.ResultSet.getTimestamp(ResultSet.java:398)

I am using latest stable JDBC driver from the http://jdbc.postgresql.org/download/pgjdbc2.jar
md5 checksum for my current version:
f4ed2deaa88e16e79ccfa1c5b1f5ca22 *pgjdbc2.jar

Any ideas, tips, help? Anyone know how to get the expected timestamp?
(In my mind it's a parsing bug in the driver, but I let somebody else make the judgement.)

Thanks for any help,
Tomi

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Drew Wilson 2002-08-03 15:31:35 Re: JDBC2 compilation errors w/ top-of-tree CVS (Darwin)
Previous Message Dave Cramer 2002-08-03 12:20:31 Re: JDBC2 compilation errors w/ top-of-tree CVS (Darwin)