Help with finding source of error.

We’ve been constantly plagued with the following error, but we cannot seem to locate where it is in our solution. Any ideas on how we might be able to pinpoint the code that is causing this error?

java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 5 to TIMESTAMP. 
    	at com.mysql.jdbc.ResultSet.getTimestampFromBytes(ResultSet.java:6864) 
    	at com.mysql.jdbc.ResultSet.getTimestampInternal(ResultSet.java:6899) 
    	at com.mysql.jdbc.ResultSet.getTimestamp(ResultSet.java:6218) 
    	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:150) 
    	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:150) 
    	at org.apache.commons.dbcp.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:150) 
    	at com.servoy.j2db.dataprocessing.BufferedDataSet.<init>(BufferedDataSet.java:85) 
    	at com.servoy.j2db.dataprocessing.SQLEngine.performSelect(SQLEngine.java:522) 
    	at com.servoy.j2db.dataprocessing.SQLEngine.performQuery(SQLEngine.java:414) 
    	at com.servoy.j2db.dataprocessing.SQLEngine.performQuery(SQLEngine.java:401) 
    	at com.servoy.j2db.dataprocessing.SQLEngine.performQuery(SQLEngine.java:143) 
    	at sun.reflect.GeneratedMethodAccessor243.invoke(Unknown Source) 
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    	at java.lang.reflect.Method.invoke(Method.java:597) 
    	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305) 
    	at sun.rmi.transport.Transport$1.run(Transport.java:159) 
    	at java.security.AccessController.doPrivileged(Native Method) 
    	at sun.rmi.transport.Transport.serviceCall(Transport.java:155) 
    	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535) 
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790) 
    	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649) 
    	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) 
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) 
    	at java.lang.Thread.run(Thread.java:619)

Thanks a ton in advance.

In MySQL, check the defaultValue of your timestamp column, chances are that it is set to ‘0000-00-00 00:00:00’, explicitely set it to null or CURRENT_TIMESTAMP (if you want it to be inserted automatically by MySQL) and the error will disappear.

Hi Chico,

You get the error because ‘0000-00-00 00:00:00’ is not a valid date so Java can’t make it into a date object.
Note that MySQL also allows you to insert dates like ‘2010-02-31 00:00:00’ (yes really) and Java will probably yell at you as well since that date doesn’t exist either.
The quickest way to make the ‘0000…’ dates go away is to do what Patricks suggests but that doesn’t solve the other invalid data issues (yes there are more then just date issues). For that you need to enable strict SQL mode in MySQL so it will enforce all the proper constraints.

Hope this helps.

Thanks guys… that helps a ton and I was able to quickly find and fix. Sweet.