Strange behaviour of rs.getTimestamp - Mailing list pgsql-jdbc

From Altaf Malik
Subject Strange behaviour of rs.getTimestamp
Date
Msg-id 416690.93407.qm@web110406.mail.gq1.yahoo.com
Whole thread Raw
Responses Re: Strange behaviour of rs.getTimestamp
List pgsql-jdbc
Hello everyone,
 I am getting a strange behaviour from rs.getTimestamp() with two specific dates. Please consider the following test case.

        Statement stmt = con.createStatement();
        stmt.executeUpdate("create table ts_test(a timestamp)");
        stmt.executeUpdate("insert into ts_test values('15-APR-09');");
        ResultSet rs = stmt.executeQuery("select * from  ts_test");
        while (rs.next()) {
            Timestamp t = rs.getTimestamp(1);
            System.out.println(rs.getString(1)+"->"+ t);
        }
        stmt.executeUpdate("drop table ts_test");

If you run this test case, I get : 2009-04-15 00:00:00->2009-04-15 01:00:00.0
Please note the values obtained from rs.getString and rs.getTimestamp are different. I get correct values if I run the same test case against JDK 1.5 (However I have noticed the same behaviour on some of the JDK 1.5's on our network)

This behaviour is for values 15 April 2009 and 1st June 2009. If I change the year or date, it works just fine. It is not because of Daylight Savings settings because on the very next day or the previous day, the value is correct. Is there something needs to be fixed in Driver or it is the JDK causing the problem?

Regards,
Altaf Malik

pgsql-jdbc by date:

Previous
From: Andreas Joseph Krogh
Date:
Subject: Add URL-property to PGXADataSource
Next
From: "Kevin Grittner"
Date:
Subject: Re: Strange behaviour of rs.getTimestamp