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

Posted 挑战者V

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java相关的知识,希望对你有一定的参考价值。

错误信息如下:

Caused by: java.sql.SQLException: Value 0000-00-00 00:00:00 can not be represented as java.sql.Timestamp

原因如下:
是因为数据表中字段类型与对象中的属性类型不一致。比如在我的数据表中是datetime类型,正常来说,对象中应该是Date类型,但是本次在对象中却是String类型。

解决办法:
(1)将datetime类型修改为varchar类型,即可解决问题;
(2)将Java对象属性类型(对应的那个)改为Date类型(java.util而非java.sql),即可解决问题;

以上是关于Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java的主要内容,如果未能解决你的问题,请参考以下文章

Mathematical Problems Caused by CCD

Caused by SSLError

Caused by: java.lang.NoClassDefFoundError:

caused by a circular import.

异常Caused by: java.lang.ClassNotFoundException: org.springframework.dao.DataIntegrityViolationExcep

Caused by org hibernate DuplicateMappingException Duplicat