java Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
来源:互联网 发布:暴风影音mac官方下载 编辑:程序博客网 时间:2024/05/15 07:30
Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp解决办法
如果你的数据库数据中有dataTime的值为“0000-00-00 00:00:00”,java jdbc操作会报错。
原因:“0000-00-00 00:00:00”在MySQL中是作为一个特殊值存在的,但是在Java中, java.sql.Date 会被视为 不合法的值,被JVM认为格式不正确。
所以要想忽略这个报错,需要在进行jdbc时候进行配置参数
在jdbc的url加上 zeroDateTimeBehavior参数:
static final String DB_URL = "jdbc:mysql://192.*.*.*:3306/dbname?zeroDateTimeBehavior=convertToNull"; //convertToNull convertToNull 转换成null,也即是Date t = getDate(); t是null
这样就可以不报错误了。
String DB_URL = "jdbc:mysql://192.*.*.*:3306/dbname?zeroDateTimeBehavior=round&characterEncoding=utf8"; // round MySQL使用全由0组成的DATETIME值来表示无效日期。
谢谢。参考:http://blog.csdn.net/bz201/article/details/50685403
0 0
- 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
- Value '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错误
- 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异常
- hiERROR: Value '0000-00-00' can not be represented as java.sql.Timestamp
- 解决: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 00:00:00' can not be represented as java.sql.Timestamp
- aop和注解将权限和操作日志与业务解耦
- 在framework中添加字符串资源
- 爬虫-漫画喵的100行逆袭
- Activity生命周期
- [Python]学习笔记(1)
- java Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- C# BASE64中文乱码问题
- 深入简出mysql
- 基于C++和OpenCv的SIFT_图像局部特征检测算法代码的实现
- 496. Next Greater Element I
- Android应用层修改LED指示灯
- 掉过的坑
- STM32F4-UCOSIII-1移植
- 跨域问题总结