All zero dates, mysql, and jdbc


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.

,

  1. No comments yet.
(will not be published)


css.php