Value '0000-00-00' can not be represented as java.sql.Date
2016-05-30 10:21
295 查看
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参数:
问题描述, 在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参数:
jdbc:mysql://192.168.1.202:3306/com?autoReconnect=true&useUnicode=true&characterset=utf8mb4&zeroDateTimeBehavior=convertToNull
相关文章推荐
- Android高级UI ViewFlipper左右滑屏切换页面
- ue4 笔记
- easyui表单校验拓展
- RSA加密local class incompatible版本异常问题
- iOS蓝牙开发--CoreBluetooth
- IOS学习之——UITextView
- UIKit框架之——TextField 文本框
- Codeforces Round #FF (Div. 1) A. DZY Loves Sequences
- iOS获得UITextView当前光标所在的位置.
- Mybatis map value 等于null无法获取值
- 小身材大用途,用PrimusUI驾驭你的页面
- 如何写好一个UITableView
- iOS中UIImagePickerController图片选取器的用法小结
- [HDOJ2818]Building Block(带权并查集,路径压缩)
- Android高级UI ProgressBar实现各种效果的圆形进度
- priority_queue
- jobbuilder.newjob
- 视图控制器
- TBB(Intel Threading Building Blocks)学习笔记
- APUE 笔记