« November 2006 | Main | January 2007 »

December 2006 Archives

December 18, 2006

Mysql null date

I had an issue with java and hibernate returning a null date.

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

This just took a little longer to find the fix on a google search than I thought it should have so I post what I ended up doing to resolve the situation here:

?zeroDateTimeBehavior=convertToNull

you add this to your jdbc connection url and it will convert the 0000-00-00 to the proper type for java to work with.

More info here:

http://dev.mysql.com/doc/mysql/en/cj-upgrading.html#cj-upgrading-3-0-to-3-1

thanks to this thread, which had many other suggestions, but most of them were not helpful, but the one above saved my day.

http://forum.java.sun.com/thread.jspa?threadID=649520&messageID=3824019

you can add this on the end of your hibernate connection file, like so...
jdbc:mysql://{DB_IPADDRESS}:{DB_PORT}/{DB_NAME}?zeroDateTimeBehavior=convertToNull&profileSql=true

Web 2.0 craziness

View Dan Mayer's profile on LinkedIn


I Power Seekler
I Power Seekler

www.flickr.com
This is a Flickr badge showing public photos and videos from mayer_dan. Make your own badge here.

Creative Commons License
This weblog is licensed under a Creative Commons License.