Thursday, June 18, 2009

Andy Jarrett: MySQL, JDBC Driver and zero dates

Andy Jarrett: MySQL, JDBC Driver and zero dates: "Error Executing Database Query.<br/>
Cannot convert value '0000-00-00 00:00:00' from column xxxx to TIMESTAMP.

This is caused by Java as it cannot handle zero dates ('0000-00-00 00:00:00'), it trys to do anything it can with them but convert them to the original date :o). To get round this you can set a parameter in the JDBC URL called zeroDateTimeBehavior to convertToNull.

So in your Data Sources page you should have something similar to:


jdbc:mysql://localhost:3306/mySqlDatabase?zeroDateTimeBehavior=convertToNull"

0 comments: