Re: JDBC driver throws SQLException while parsing timestamp
От | Bruce Momjian |
---|---|
Тема | Re: JDBC driver throws SQLException while parsing timestamp |
Дата | |
Msg-id | 200101262010.PAA02071@candle.pha.pa.us обсуждение исходный текст |
Ответ на | JDBC driver throws SQLException while parsing timestamp (pgsql-bugs@postgresql.org) |
Список | pgsql-bugs |
I think this is fixed in 7.1beta. > 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 > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
В списке pgsql-bugs по дате отправления: