ResultSet.getTimestamp throws exception for 0000-00-00 00:00:00 in 3.1 gamma
Posted by: Rich Collins
Date: December 16, 2004 05:10PM

I, like many others, use '0000-00-00 00:00:00' to represent a null date value for datetime and timestamp fields in mysql databases. Prior to the 3.1 Connector, calling ResultSet.getTimestamp method would return null. Now it throws an exception with the stack trace:

java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 10 to TIMESTAMP.
at com.mysql.jdbc.ResultSet.getTimestampFromString(ResultSet.java:6362)
at com.mysql.jdbc.ResultSet.getTimestampInternal(ResultSet.java:6387)
at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:2263)
at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:2295)

If this continues to be the case, I, like many others, will never be able to upgrade to mysql 4.1 as it would be impossible to refactor the code everywhere this basic operation is executed.

Thanks,

Rich Collins

Options: ReplyQuote


Subject
Written By
Posted
ResultSet.getTimestamp throws exception for 0000-00-00 00:00:00 in 3.1 gamma
December 16, 2004 05:10PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.