From: | pgsql-bugs(at)postgresql(dot)org |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | JDBC driver throws SQLException while parsing timestamp |
Date: | 2001-01-25 11:28:57 |
Message-ID: | 200101251128.f0PBSvI28834@hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Alexander Dietrich (adietrich(at)webantz(dot)com) reports a bug with a severity of 2
The lower the number the more severe it is.
Short Description
JDBC driver throws SQLException while parsing timestamp
Long Description
Hi,
there's a discrepancy between PreparedStatement.setTimestamp() and
ResultSet.getTimestamp() related to a timestamp format that may or
may not be valid (sorry I can't give a complete code sample):
-----
I do something like this to store the timestamp:
Connection conn = ConnectionFactory.getConnection();
PreparedStatement stmt = conn.prepareStatement(getInsertString());
[...]
stmt.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
stmt.executeUpdate();
-----
This is an example of what ends up in the database:
type: timestamp, value: "2001-01-25 11:33:19.50+01"
(Checked with psql)
-----
But when retrieving the data:
[...]
ResultSet rs = stmt.executeQuery(queryStr);
Timestamp timestamp = rs.getTimestamp("CREATION_TIME");
An SQLException is thrown:
Bad Timestamp Format at 19 in 2001-01-25 11:33:19.50+01
java.lang.Throwable()
java.lang.Exception()
java.sql.SQLException()
org.postgresql.util.PSQLException(java.lang.String, java.lang.Object, java.lang.Object)
java.sql.Timestamp org.postgresql.jdbc2.ResultSet.getTimestamp(int)
java.sql.Timestamp org.postgresql.jdbc2.ResultSet.getTimestamp(java.lang.String)
[...]
-----
Obviously the getTimestamp() method chokes on the millisecond field
in the timestamp. A timestamp like "2001-01-25 11:33:19+01" does not
pose a problem.
My configuration is:
Server:
RedHat 7.0 (x86), 2.2.16-22
postgresql-server-7.0.3-2
postgresql-7.0.3-2
postgresql-jdbc-7.0.3-2
Client:
JVM: 1.2.2 inside VisualAge 3.5 Patch 2
JDBC driver: jdbc7.0-1.2.jar
Regards,
Alexander Dietrich
Sample Code
No file was uploaded with this report
From | Date | Subject | |
---|---|---|---|
Next Message | pgsql-bugs | 2001-01-25 11:54:20 | large objects overwriting bug |
Previous Message | Max Vaschenko | 2001-01-25 10:34:02 | BUG in postgres mathematic |