解决Value '0000-00-00 ' can not be represented as java.sql.Timest
2015-12-04 13:51
483 查看
在使用MySql 时, 数据库中的字段类型是timestamp的,默认为0000-00-00, 会发生异常:java.sql.SQLException: Value '0000-00-00 ' can not be represented as java.sql.Timestamp
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,
对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
解决办法:
给jdbc url加上 zeroDateTimeBehavior参数:
datasource.url=jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true
zeroDateTimeBehavior=round是为了指定MySql中的DateTime字段默认值查询时的处理方式;默认是抛出异常,
对于值为0000-00-00 00:00:00(默认值)的纪录,如下两种配置,会返回不同的结果:
zeroDateTimeBehavior=round 0001-01-01 00:00:00.0
zeroDateTimeBehavior=convertToNull null
相关文章推荐
- easyui--spinner
- spoj375 Query on a tree(树链剖分 边权 入门题)
- [MSSQL]在T-SQL语句中访问远程数据库(openrowset/opendatasource/openquery)
- 键盘(UITextInputTraits)
- Ⅰ.15 如何修改Squish函数
- easyui--datebox
- UESTC 764 失落的圣诞节 直接or线段树orRMQ
- iOS UIViewController 无法关闭自动旋屏(自动旋转、手动旋转、兼容IOS6之前系统)
- LeetCode(303)Range Sum Query - Immutable
- LeetCode(303)Range Sum Query - Immutable
- easyui--calendar日历组件
- requireJs笔记一
- LeetCode(303) Range Sum Query - Immutable解题报告
- iOS-UIKit( UIVisualEffectView.h - -解读)
- UINavigationController的popViewControllerAnimated的控制器移除问题
- 解决下载Android Build-tools 19.1.0失败
- 【iOS Programming: The Big Nerd Ranch Guide】【笔记】2
- UIResponder(iOS 常见的事件)
- UIResponder(iOS 常见的事件)
- 高仿大众点评7.9.0UI界面实现(附带源码)