java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql
来源:互联网 发布:js求数组中的最大值 编辑:程序博客网 时间:2024/05/16 11:08
转载地址:http://blog.csdn.net/ja_ii_ck/article/details/3905120
问题描述:
数据表中有记录的time字段(属性为timestamp)其值为:“0000-00-00 00:00:00”
程序使用select 语句从中取数据时出现以下异常:
java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
后查资料发现 “0000-00-00 00:00:00”在mysql中是作为一个特殊值存在的
但 java.sql.Date 将其视为 不合法的值 格式不正确
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/pe?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull
zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,
对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
0 0
- Err: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.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date 解决方法
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- [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.Date .
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.D
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql
- java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timest
- java.sql.SQLException:Value ’0000-00-00′ can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 问题解决:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- 浅谈Java串行端口技术协议
- build vp8 on android
- 学习软件技术的2、3点
- java线程之间的通信
- 经典算法--希尔排序
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql
- 内核为2.6.22.1,在做pvmove时出现错误
- 学习OpenCV——BOW特征提取函数(特征点篇)
- 财务人员如何更好的抵御寒冬?
- 各种错误可能原因,调试经验
- websocket
- Xcode中Build Settings中的变量@rpath,@loader_path,@executable_path
- 驴子圈
- JAVA操作串口有感