java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date(已解决)
程序员文章站
2022-04-21 13:17:27
...
问提描述:数据表中有记录的time字段(属性为timestamp)其值为:“0000-00-00 00:00:00”
出现异常:java.sql.SQLException: Value ‘0000-00-00’ can not be represented as java.sql.Date
原因:0000-00-00 00:00:00”在mysql中是作为一个特殊值存在的,但 java.sql.Date 将其视为 不合法的值 格式不正确。
解决方法:url后加上:&zeroDateTimeBehavior=convertToNull
String url = "jdbc:mysql://localhost:3306/testuseUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull";
推荐阅读
-
解决:java.sql.SQLException:Value ‘0000-00-00‘ can not be represented as java.sql.Date
-
java.sql.SQLException: Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp异常
-
FAQ(60):java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
-
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Tim 异常解决办法
-
mysql错误:Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;的解决方法
-
FAQ(64):java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
-
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date(已解决)
-
java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp at
-
java.sql.SQLException: Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
-
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date