MYSQL '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
来源:互联网 发布:怎么在u盘中装ubuntu 编辑:程序博客网 时间:2024/06/10 03:06
在使用MySql 时, 数据库中的字段类型是timestamp的,默认为0000-00-00, 会发生异常:java.sql.SQLException: Value ‘0000-00-00 ’ can not be represented as java.sql.Timestamp.
数据库里面默认值是这一串0,但是JDBC不能将'0000-00-00 00:00:00'转化为一个为一个java.sql.Timestamp,在Java中,想创建一个java.util.Date,使其值为 '0000-00-00'也是不可能的,最古老的日期应该是'0001-01-01 00:00:00',所以报错了。
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
zeroDateTimeBehavior=convertToNull
默认:
取值exception:
driver-url=jdbc:mysql://127.0.0.1/test?zeroDateTimeBehavior=exception
************************************这是里job调用dao的报错。所以在job里面需要捕获异常,防止job遇到异常停止。
0 0
- MYSQL '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- mysql Value '0000-00-00' can not be represented as java.sql.Timestamp
- mysql抛出Value '0000-00-00' can not be represented as java.sql.Timestamp异常
- Err:java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
- [DEBUG] “java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
- java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
- “java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp”
- java Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error
- Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- ERROR: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- 提示Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;
- Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
- Value '0000-00-00' can not be represented as java.sql.Timestamp
- Value '0000-00-00' can not be represented as java.sql.Timestamp错误
- JAVA入门篇(一)
- 矩阵图求最优最大值问题(简单dp)
- (英文)网络、短信、邮件常用缩略语
- iScroll5 API速查随记
- Android WebView使用基础
- MYSQL '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- 对Map集合的遍历
- 虚函数与多态性
- 哈夫曼树和哈夫曼编码
- Mybatis之实现分页
- SVD & PCA
- Binary Tree Level Order Traversal
- throw throws 区别
- HDU1022——Train Problem I(栈 stack)