Re: Strange behaviour of rs.getTimestamp

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <pgsql-jdbc(at)postgresql(dot)org>,"Altaf Malik" <mmalik_altaf(at)yahoo(dot)com>
Subject: Re: Strange behaviour of rs.getTimestamp
Date: 2011-01-06 14:56:18
Message-ID: 4D2583B20200002500039059@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Altaf Malik <mmalik_altaf(at)yahoo(dot)com> wrote:

>> 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

You didn't read very closely -- you said some machines gave the
right answer and some the wrong answer. Clearly there's something
different from one to the other. What?

>> 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:

No, that was a code snippet. I fleshed it out to a compilable
source file like this:

import java.sql.*;
public final class TestTS
{
public static void main(String[] args) throws Exception
{
Class.forName("org.postgresql.Driver");
Connection con = DriverManager.getConnection
("jdbc:postgresql:test", "test", "test");
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");
System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.version"));
System.out.println(System.getProperty("java.vm.name"));
System.out.println(System.getProperty("java.vm.info"));
while (rs.next()) {
Timestamp t = rs.getTimestamp(1);
System.out.println(rs.getString(1)+"->"+ t);
}
rs.close();
stmt.executeUpdate("drop table ts_test");
stmt.close();
con.close();
}
}

When I compile and run, I get this:

Sun Microsystems Inc.
1.6.0_21
Java HotSpot(TM) Client VM
mixed mode, sharing
2009-04-15 00:00:00->2009-04-15 00:00:00.0

Unless you provide more information, nobody can help.

-Kevin

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kevin Grittner 2011-01-06 17:55:03 Re: port problem
Previous Message Altaf Malik 2011-01-06 14:50:04 Re: Strange behaviour of rs.getTimestamp