Java教程

Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp; nested exception

本文主要是介绍Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp; nested exception,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

好久没记录了,最近一直在忙着工作以及码前后端 记录下这种大多数人都会碰到但是又不一定找得到问题的错误

 1 Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp; nested exception is java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp 

 

 

 一般是数据库表设计字段为DateTime类型时数据库默认给了0000-00-00这种默认值,在数据库看来是合法合理的,但是在jvm中并不认可

 

因此,做法无非就是让他输出的默认值变为 null  或者  有正确的默认值输出

 

解决方法也很简单:在数据库链接后加上  &zeroDateTimeBehavior=convertToNull   这样输出默认值为null  就不会报错了

 

这篇关于Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp; nested exception的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!