Getting the exception like "Cannot convert value '0000-00-00 00:00:00' from column 12 to TIMESTAMP"

Previously the column Data type is Date now I am changed to Timestamp Now if I tried to run the program am getting them exception

java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 12 to TIMESTAMP. at com.mysql.jdbc.ResultSetRow.getTimestampFast( at com.mysql.jdbc.ByteArrayRow.getTimestampFast( at com.mysql.jdbc.ResultSetImpl.getTimestampInternal( at com.mysql.jdbc.ResultSetImpl.getTimestamp( at com.mysql.jdbc.ResultSetImpl.getTimestamp( at org.hibernate.type.TimestampType.get( at org.hibernate.type.NullableType.nullSafeGet( at org.hibernate.type.NullableType.nullSafeGet( at org.hibernate.type.AbstractType.hydrate( at org.hibernate.persister.entity.AbstractEntityPersister.hydrate( at org.hibernate.loader.Loader.loadFromResultSet( at org.hibernate.loader.Loader.instanceNotYetLoaded( at org.hibernate.loader.Loader.getRow( at org.hibernate.loader.Loader.getRowFromResultSet( at org.hibernate.loader.Loader.doQuery( at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections( at org.hibernate.loader.Loader.doList( ... 40 more


0000-00-00 00:00:00 is outside the range of a TIMESTAMP value (in fact, it won't work with a DATE field either). From the MySQL manual:

The TIMESTAMP data type has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

You can just add zeroDateTimeBehavior=convertToNull to your connection jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull.

For me, it works perfectly. pls refer to this link for more detail.

You can Use UNIX_TIMESTAMP(date) function to explicitly convert the value to TIMESTAMP.

I'm going to take a wild guess here that you're using MySQL :-) It uses "zero dates" as special placeholder - unfortunatelly, JDBC can not handle them by default.

The solution is to specify "zeroDateTimeBehavior=convertToNull" as parameter to your MySQL connection (either in datasource URL or as an additional property), e.g.:


This will cause all such values to be retrieved as NULLs.

Make sure that in you java code the field type is java.sql.Timestamp

Need Your Help

hibernate-schema-plugin validate goal

hibernate maven-plugin

has anyone here used the hibernate-schema-plugin from vecna technologies? I was wondering how to execute the validate goal from the command line. Here's the documentation:

Android - Another button question

android eclipse image button scale

Its a dumb question. Prepare yourself.