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

From Altaf Malik
Subject Re: Strange behaviour of rs.getTimestamp
Date
Msg-id 766302.42702.qm@web110412.mail.gq1.yahoo.com
Whole thread Raw
In response to Re: Strange behaviour of rs.getTimestamp  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: Strange behaviour of rs.getTimestamp
List pgsql-jdbc

> So, what's different between the ones that yield the correct values
> and the ones that don't?

Please look at the values:
2009-04-15 00:00:00->2009-04-15 01:00:00.0

The value I inserted in table was 2009-04-15 00:00:00 and from rs.getString(1) I got the same value. rs.getTimestamp(1) returned me a different value (note the hour value is 1 instead of 0). The value I got is: 2009-04-15 00:00:00


> If you can put together a self-contained test case that someone can
> compile and run on their own machine, it becomes much easier for
> others to understand the problem and to help.

I did so. Please read the following portion carefully:

    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");


Regards,
Altaf Malik

pgsql-jdbc by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Strange behaviour of rs.getTimestamp
Next
From: "Kevin Grittner"
Date:
Subject: Re: Strange behaviour of rs.getTimestamp