miércoles, abril 23, 2008

java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date

These haterz at mysqlAB have changed the behaviour for MySQL Connector from 30 to the 3.1.x versions, now The Date column type cannot be mapped to a Date java Object when it is null, just because the null default value in mysql is not NULL, but '0000-00-00'

This is the message:

java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date

The mysql version is: 4.1.14
the MySQL Connector/J is: mysql-connector-java-3.1.6-bin.jar

The easy way of getting out of there and not get the exception is passing "zeroDateTimeBehavior=convertToNull" as a parameter to your jdbc url, like:

jdbc:mysql://kraftek.com/alox?zeroDateTimeBehavior=convertToNull

The hard way is to change your old code to passthrough that...

suckerz






Obtenido de:

http://www.kraftek.com/blog/index.php?/archives/
105-java.sql.SQLException-Value-0000-00-00-can-
not-be-represented-as-java.sql.Date.html