JDBC-Driver produces wrong output. - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject JDBC-Driver produces wrong output.
Date
Msg-id 200011020934.eA29Y8b72201@hub.org
Whole thread Raw
List pgsql-bugs
Jan Thomae (jan@smb-tec.com) reports a bug with a severity of 2
The lower the number the more severe it is.

Short Description
JDBC-Driver produces wrong output.

Long Description
Hi,

I recently downloaded the last snapshot of PostgreSQL and also the newest JDBC-Driver for it. I played a bit around
withit and it seems to produce some really weird output on datetimes and timestamps. I added a table "test" into the
database,containing two columns "test1" and "test2". "test1" is a timestamp, "test2" a datetime. Then I entered the
followingdate into each of the columns: 15.10.1978 20:47:56 CET. After this I ran a small test program (see the
attachedsource code). This produced the following output: 

|1981-11-15 20:00:56.0|1981-11-15 20:00:56.0

As you can see, the dates are different from what I entered into the database. This error did not occur using the 6.4
PostgreSQLand belonging driver. Do I do something wrong ? 

Sample Code
Hashtable defaultProperties = new Hashtable();
defaultProperties.put(JDBCResource.HOSTNAME, "frodo");
defaultProperties.put(JDBCResource.PORT, "5432");
defaultProperties.put(JDBCResource.USERNAME, "jan");
defaultProperties.put(JDBCResource.PASSWORD, "");
defaultProperties.put(JDBCResource.DATABASE, "testdb");

Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection(...)
Statement statement = connection.createStatement();

ResultSet rs = statement.executeQuery("SELECT * FROM test");
while (rs.next()) {
   int cols = rs.getMetaData().getColumnCount();
   for (int i=1; i<=cols; i++) {
       System.out.print("|" + rs.getObject(i));
   }
   System.out.println("");
}
rs.close();


No file was uploaded with this report

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: Joins on over 10 tables returns unreliable results
Next
From: Jan Thomae
Date:
Subject: My Bug report: JDBC-Driver produces wrong output.