java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
来源:互联网 发布:sql标识符的命名规则 编辑:程序博客网 时间:2024/04/29 07:00
问题描述:java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
问题描述:
数据表中有记录的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
zeroDateTimeBehavior=convertToNull null
- 问题解决: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
- 解决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
- 程序bug调试以及java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date问题
- DSP数据格式
- DB2常用命令
- PB函数--find
- WPF/Silverlight深度解决方案:(十六)传值实现
- 使用 getopt() 进行命令行处理
- java.sql.SQLException:Value '0000-00-00' can not be represented as java.sql.Date
- Setting Up a Maven Repository
- DB2备份脚本
- Quartz的表达式
- 根绝日志还原数据
- jQuery 插件收藏(2)NotesForLightBox
- DB2恢复脚本
- How to store an image file to SQliteDB in android
- Eclipse 中三大框架的集成及相应插件的安装