Problem Description:
The data table has a record time field (property of timestamp) whose value is:"0000-00-00 00:00:00"
The following exception occurs when a program uses the select statement to fetch data from:
Java.sql.SQLException:Value ' 0000-00-00 ' can not is represented as Java.sql.Date
post-search data found "0000-00-00 00:00:00" is present in MySQL as a special value.
but java.sql.Date it as an illegal value is not formatted correctly
Workaround:
add The Zerodatetimebehavior parameter to the JDBC URL :
datasource.url=jdbc:mysql://localhost:3306/pe?useunicode=true&characterencoding=gbk& Zerodatetimebehavior=converttonull
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 .
For records with a value of 0000-00-00 00:00:00(the default), the following two configurations will return different results:
Zerodatetimebehavior=round 0001-01-01 00:00:00.0
Zerodatetimebehavior=converttonull NULL
This article is from "Doyle" blog, please make sure to keep this source http://conandoyle.blog.51cto.com/11462365/1766953
Java.sql.SQLException:value; ' 0000-00-00 ' can not is represented as Java.sql.date