Value '0000-00-00' can not be represented as java.sql.Date解决办法
来源:互联网 发布:安云加速器for mac 编辑:程序博客网 时间:2024/06/07 09:49
Java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
问题描述, 在java应用程序中,数据表中有记录的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中, java.sql.Date 会被视为 不合法的值,被JVM认为格式不正确。
解决办法:
在jdbc的url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/pe?useUnicode=true&characterEncoding=gbk&zeroDateTimeBehavior=convertToNull
对于值为0000-00-00 00:00:00(默认值)的纪录,根据不同的配置,会返回不同的结果:
不配置:默认返回异常
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
0 0
- Value '0000-00-00' can not be represented as java.sql.Date解决办法
- Value '0000-00-00' can not be represented as java.sql.Date解决办法
- 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
- 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
- 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
- 本机连接虚拟机中Oracle数据库问题解决
- C++构造函数和析构函数
- NFS 远程实时写入同步
- html如何让取消横向缩放
- laravel phpstorm安装laravel-ide-helper实现自动完成、代码提示和跟踪
- Value '0000-00-00' can not be represented as java.sql.Date解决办法
- 屏幕尺寸、分辨率、像素、PPT解释及其关系
- POJ 1050 To the Max
- C++作业4
- 最短路径(由浅到深)
- 循环赛日程问题
- 百宝云是什么?
- TestFlight Beta 相关问答
- 了解javascript闭包是什么?