使用hibernate开发程序的时候,有的时间字段没有必要填写,但是,以后hibernate查询的时候会报出
“java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
的错误, 这是因为hibernate认为这个不是一个有效的时间字串。
方法一:
将 日期改为合格的日期。
方法二:
mysql连接串加上
jdbc:mysql://localhost/schoolmis?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull
在使用Hibernate进行开发时,遇到一个常见的问题:当时间字段未填充时,查询会抛出'java.sql.SQLException: Value '0000-00-00' cannot be represented as java.sql.Timestamp'的错误。解决方法包括修改日期为有效格式或者在MySQL连接串中添加'zeroDateTimeBehavior=convertToNull'参数来避免此问题。

1182

被折叠的 条评论
为什么被折叠?



