且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将“0000-00-00 00:00:00”转换为TIMESTAMP

更新时间:2022-11-01 15:08:07

我将在这里猜测你正在使用MySQL :-)它将零日期用作特殊占位符 - 不幸的是,JDBC无法处理它们默认情况下

I'm going to take a wild guess here that you're using MySQL :-) It uses "zero dates" as special placeholder - unfortunatelly, JDBC can not handle them by default.

解决方案是将zeroDateTimeBehavior = convertToNull指定为MySQL连接的参数(在数据源URL或附加属性中),例如: p>

The solution is to specify "zeroDateTimeBehavior=convertToNull" as parameter to your MySQL connection (either in datasource URL or as an additional property), e.g.:

jdbc:mysql://localhost/myDatabase?zeroDateTimeBehavior=convertToNull

这将导致所有这些值被检索为NULL。

This will cause all such values to be retrieved as NULLs.