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

MySql 数据库中的字段类型是timestamp的,默认为0000-00-00, 会发生异常:java.sql.SQLException:   Value   '0000-00-00 '   can   not   be   represented   as   java.sql.Timestamp 


解决办法:


给jdbc   url加上   zeroDateTimeBehavior参数: 


datasource.url=jdbc:mysql://localhost:3306/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull




对于值为0000-00-00   00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果: 


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


zeroDateTimeBehavior=convertToNull   null   

你可能感兴趣的:(java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timest)