aggregate functions and timestamps in JDBC, possible bug? - Mailing list pgsql-jdbc

From Tomi Panula-Ontto
Subject aggregate functions and timestamps in JDBC, possible bug?
Date
Msg-id 000801c23af0$f43aee20$fb00a8c0@komialand
Whole thread Raw
Responses Re: aggregate functions and timestamps in JDBC, possible bug?
List 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
 
 
 

pgsql-jdbc by date:

Previous
From: Aditya
Date:
Subject: jdk1.4.1 Password authentication failed for user. md5 support?
Next
From: sabarish kr
Date:
Subject: product information