Tuesday, January 15, 2013

Re: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

I wrestled with this problem and implemented the URL concatenation solution contributed by @Kushan in the accepted answer above. It worked in my local MySql instance. But when I deployed my Play/Scala app to Heroku it no longer would work. Heroku also concatenates several args to the DB URL that they provide users, and this solution, because of Heroku's use concatenation of "?" before their own set of args, will not work. However I found a different solution which seems to work equally well.

    SET sql_mode = 'NO_ZERO_DATE';

I put this in my table descriptions and it solved the problem of
    '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp


On Sunday, March 11, 2012 2:19:33 PM UTC-7, Markus Unger wrote:
Hey!

I have a Timestamp Field with a Null Value. But the JDBC say the following error message:

Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

Seems that MySQL convert a null timestamp into '0000-00-00 00:00:00. Anybody prefered to set this flag zeroDateTimeBehavior=convertToNull

But I found no way to set it in Cloud SQL. Is it possible to set this flag?

Regards, 

Markus

No comments:

Post a Comment