Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
来源:互联网 发布:淘宝买家秀点赞没了 编辑:程序博客网 时间:2024/05/02 01:16
最近在做的屋祺项目,保养/维修检验管理模块有这样一个需求:当客户提交申请后会有相应的技术人员上门服
务,其中实际到达时间当技工人员到达前为空,在客户点击技工已到达后更新技工到达时间。如下图所示:
在给页面绑定数据的过程中遇到下面一个错误:
Error querying database. Cause: java.sql.SQLException: Value'0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
上网查了一下相关资料,原来是因为实际到达字段在数据库中可为空,其默认值为“0000-00-0000:00:00”,在
mysql中作为一个特殊值存在。但是在java项目编译的时候会被视为不合法的值,被JVM认为格式不正确。
解决方案
在配置数据库连接的url上添加zeroDateTimeBehavior的配置。对于值为空的记录,配置不同,返回的结果也不同。
1)没有配置。抛出异常如上所示
2)zeroDateTimeBehavior=round 返回值为 0001-01-01 00:00:00.0
3)zeroDateTimeBehavior=convertToNull 返回值为 null
保存程序后运行,又抛出新的异常
The reference to entity "characterEncoding" must end with the ';' delimiter
这是因为在XML文件中不能直接用&表示“&”,需要将其转义为“&”,其中“amp;”就是“”的意思。
1 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
- poj 2251 Dungeon Master(BFS)
- 报表打印时提示页边距被设置到纸张可打印范围之外怎么办
- android studio gradle 友盟自动更新jar包 okio冲突
- Android自定义控件 -- 自定义ViewGroup
- Java垃圾回收GC(二)
- Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
- vs2015+ffmpeg开发环境配置
- 动画Animation两种实现方式的不同效果
- AS400遇到的一些问题和解决办法
- 基于wpa_supplicant库的WIFI连接功能实现--应用层碎片式对象内存管理算法
- 关于通过导数据出现的oracle字符集问题
- 欢迎使用CSDN-markdown编辑器
- 3·15晚会报道的无人机是怎么被劫持的?
- 面向对象的基础和特征