6 Replies Latest reply on Mar 28, 2012 5:58 AM by Jaime Poch

    java java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date. How to set zeroDateTimeBehavior=convertToNull

    Jaime Poch Newbie



      My environment: Eclipse Indigo, Jboss AS 7, mysql-connector-java-5.1.17-bin.jar


      I'm receiving this message:


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


      I know this is because the mysql driver don't accept the '0000-00-00' as a null value and by defult it throws this exception. I have been investigating in the Internet and I found often the solution of adding to the connection url the following text: ?zeroDateTimeBehavior=convertToNull. For example, jdbc:mysql://localhost:3306/databasename?zeroDateTimeBehavior=convertToNull.


      I tried to do this in the datasource configuration in the administrator area of jboss as7 but doesn't work. I think I can't configura that this way.


      Where can I configure zeroDateTimeBehavior value to convertToNull?