Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java - Mysql Datetime problem

807599Nov 15 2006 — edited Nov 19 2006
My problem is the following:
I've got a mysql-table with fields of the type DATETIME. These have the default value "0000-00-00 00:00:00". When I now call rs.getXXX() on one of these columns with their default value, I get the following SQL error:
java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column xx to TIMESTAMP.
	at com.mysql.jdbc.ResultSet.getTimestampFromString(ResultSet.java:5639)
	at com.mysql.jdbc.ResultSet.getTimestampInternal(ResultSet.java:5667)
	at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:5320)
	at com.mysql.jdbc.ResultSet.getObject(ResultSet.java:4433)
	[some more lines]
maybe this error also occurs with DATE fields '0000-00-00'. Didn't tested it yet.
any ideas for a good solution? At the moment I catch the exception, check if it looks like this one and then "manually" use '0000-00-00 00:00:00'. But this really isn't a good solution for me. ;)

mfg kai

(sorry for my bad english :D )

Message was edited by:
kai_schwierczek
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 17 2006
Added on Nov 15 2006
7 comments
2,183 views