JDBC driver throws SQLException while parsing timestamp
От | pgsql-bugs@postgresql.org |
---|---|
Тема | JDBC driver throws SQLException while parsing timestamp |
Дата | |
Msg-id | 200101251128.f0PBSvI28834@hub.org обсуждение исходный текст |
Ответы |
Re: JDBC driver throws SQLException while parsing timestamp
|
Список | pgsql-bugs |
Alexander Dietrich (adietrich@webantz.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
В списке pgsql-bugs по дате отправления: