When the default insertion value for Mysql time format is null, it will be populated with ' 0000-00-00 00:00:00 ', at which point the sqlexecption will be thrown if the select is as follows:
Java.sql.SQLException:Value ' 0000-00-00 00:00:00 ' can not is represented as Java.sql.Timestamp
Here's how to fix it:
method One: jdbc URL plus zerodatetimebehavior parameter:
datasource.url=jdbc:mysql://localhost:3306/testdb?useunicode=true&characterencoding=utf-8& Zerodatetimebehavior=converttonull&transformedbitisboolean=true
Zerodatetimebehavior=round is to specify how the DateTime field in MySQL is to be processed when the default value query is queried, and the default is to throw an exception.
(Excerpt from: http://www.blogjava.net/hilor/articles/164814.html)
Method Two: The SELECT statement is handled as follows:
SELECT ID, IF (createdate= ' 0000-00-00 00:00:00 ', ' null ', CreateDate) createdate from T_datetest;
This converts the createdate format to a "null" display and no longer throws the SqlException.
Mysql time format default empty string ' 0000-00-00 00:00:00 ' select throws Exception resolution