JDBC-Driver produces wrong output.

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC-Driver produces wrong output.
Date: 2000-11-02 09:34:08
Message-ID: 200011020934.eA29Y8b72201@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Jan Thomae (jan(at)smb-tec(dot)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 with it 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 following date into each of the columns: 15.10.1978 20:47:56 CET. After this I ran a small test program (see the attached source 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 PostgreSQL and 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

Browse pgsql-bugs by date

  From Date Subject
Next Message Jan Thomae 2000-11-02 10:56:06 My Bug report: JDBC-Driver produces wrong output.
Previous Message Tom Lane 2000-11-02 07:41:28 Re: Joins on over 10 tables returns unreliable results