'0000-00-00' is not a java.sql.Date

Help
Garthfield
2010-10-13
2013-04-29
  • Garthfield
    Garthfield
    2010-10-13

    This error comes up constantly and it's because MySQL's default value for an IS NULL date is '0000-00-00', Java doesn't like this as it isn't a correct date. To fix this you need to add "&zeroDateTimeBehavior=convertToNull" to the connection string. However I've done this and SQL explorer ignores the ampersand and joins it altogether with the database name which then gives an unknown database error.

    Any ideas of how to get around this?

     
  • Heiko Hilbert
    Heiko Hilbert
    2010-10-13

    A connection URL is an URL so you have to start the query string part with an ?. The format is:

    jdbc:mysql://<server>/<database>?zeroDateTimeBehavior=convertToNull

    If youe want to add additional parameters use an & as separator:

    jdbc:mysql://<server>/<database>?zeroDateTimeBehavior=convertToNull&param2=value2

    HTH