java.sql.SQLException: Value'0000-00-00' exception solution

When using MySql, the field type in the database is timestamp, the default is 0000-00-00, an exception will occur: java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timestamp


Solution:

add zeroDateTimeBehavior parameter to jdbc url:

datasource.url=jdbc:mysql://localhost:3306/dbName?useUnicode=true&characterEncoding=utf-8& zeroDateTimeBehavior=convertToNull &transformedBitIsBoolean=true


zeroDateTimeBehavior=round is to specify DateTime in MySql The processing method of the field default value query; the default is to throw an exception.

For the record with the value of 0000-00-00 00:00:00 (default value), the following two configurations will return different results:

zeroDateTimeBehavior=round 0001 -01-01 00:00:00.0

zeroDateTimeBehavior=convertToNull null  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326397635&siteId=291194637