Posts Tagged jdbc
All zero dates, mysql, and jdbc
Posted by Bricky in Programming on April 3rd, 2009
Cannot convert value '0000-00-00 00:00:00' from column N to TIMESTAMP
Familiar? This problem arises because ‘null’ dates in MySql are generally represented as ‘0000-00-00 00:00:00′, which, while valid in MySql, are completely forbidden in jdbc.
There is a wonderful workaround however, simply add the zeroDateTimeBehavior parameter to the end of your jdbc url as follows:
jdbc:mysql://hostname/dbname?zeroDateTimeBehavior=convertToNull
And that’s it, zero dates will be converted to nulls and jdbc will be happy.
Popularity: 7% [?]