E
elektrophyte
I have a MySQL DB with a DATETIME column and some JDBC code that gets
dates out of it like this:
java.sql.Date d = rs.getDate(myColumn);
It works fine if the value in the column is an actual date. However, to
support the option of users not entering anything into that field, I've
made the column nullable. Apparantly in MySQL a null datetime becomes
"0000-00-00 00:00:00".
When I try to execute the Java code above and the value in the column
is "0000-00-00 00:00:00", I get this error:
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be
represented as java.sql.Date
com.mysql.jdbc.ResultSet.getDateFromString(ResultSet.java:4738)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1055)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1012)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1026)
[ ... ]
Has anyone else dealt with this issue, and if so, is there a way around
it?
Thanks,
E
I'm working with MySQL 4.0 and JDK 1.5.0_04
dates out of it like this:
java.sql.Date d = rs.getDate(myColumn);
It works fine if the value in the column is an actual date. However, to
support the option of users not entering anything into that field, I've
made the column nullable. Apparantly in MySQL a null datetime becomes
"0000-00-00 00:00:00".
When I try to execute the Java code above and the value in the column
is "0000-00-00 00:00:00", I get this error:
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be
represented as java.sql.Date
com.mysql.jdbc.ResultSet.getDateFromString(ResultSet.java:4738)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1055)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1012)
com.mysql.jdbc.ResultSet.getDate(ResultSet.java:1026)
[ ... ]
Has anyone else dealt with this issue, and if so, is there a way around
it?
Thanks,
E
I'm working with MySQL 4.0 and JDK 1.5.0_04