Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
一、问题分析
问题
Error querying database. Cause: java.sql.SQLException: Value'0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
分析
datetime数据库中可为空,其默认值为“0000-00-0000:00:00”,因MySQL的时间类型datetime范围是1000-01-01 00:00:00 到 9999-12-31 23:59:59,所以报错。
二、解决方案
1、在配置数据库连接的url上添加zeroDateTimeBehavior的配置。
示例:
修改前jdbc配置:
jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&characterSetResults=UTF-8
修改后jdbc配置 :
jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull
2、zeroDateTimeBehavior的所有配置:
Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp相关推荐
- mysql解决Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
同步发布:http://www.yuanrengu.com/index.php/mysqlsolvetimestamp.html 在使用mysql时,如果数据库中的字段类型是timestamp,默认为 ...
- 错误:Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp;的解决
问题: 代码中查询MySQL的结果集时报错,提示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.Time ...
- 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 分析: ...
- 已解决:java.sql.SQLException: Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp
一.问题 一大早到公司 Mysql 中的一个 datetime 字段时碰到了一个 Cause: java.sql.SQLException: Value '0000-00-00 00:00:00' c ...
- MySQL 错误【四】Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp
1. 错误描述 在使用mysql时,如果数据库中的字段类型是timestamp,默认为0000-00-00,会发生异常:Value '0000-00-00 00:00:00' can not be r ...
- Cause: java.sql.SQLExceptioValue ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp
今天使用mybatis创建demo测试的时候发现了一个有意思的bug org.apache.ibatis.exceptions.PersistenceException: ### Error quer ...
- Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp
程序使用select 语句查询数据时,出现以下异常: java.sql.SQLException:Value '0000-00-00' can not be represented as java.s ...
- MySQL错误:Value ‘0000-00-00 00:00:00‘ can not be represented as java.sql.Timestamp
java项目,使用MySQL,字段类型为timestamp,字段值默认为0000-00-00 00:00:00. 在解析数据时会抛出一个异常: java.sql.SQLException: Value ...
最新文章
- angular 打印 lodop 引入css样式
- hdu 1026 bfs+记录路径
- Living in the Matrix with Bytecode Manipulation--转
- Ubuntu下构建gstreamer开发环境
- 如何使用python装饰器_Python学习之如何使用装饰器 @decorator
- 深入理解前端跨域问题的解决方案——前端面试
- 接收POst数据流数据
- 计算机网络第七版谢希仁课后答案第三章(部分答案)
- java在线编辑word_java web实现在线编辑word,并将word导出(一)
- 苹果手机怎么将PDF转换成JPG图片
- 信息检索1.4.学术搜索引擎--百度学术搜索
- 图扑案例合集丨用赛博朋克语言诠释数字孪生
- win server 2008r2 相关设置
- 【WLAN】【基础知识】WIFI那些事儿之PMF
- 用Xenu检查死链发现域名后有//
- [转]电烙铁的使用小技巧
- python名片识别_基于Python的名片识别接口调用代码实例
- 如何在网页中添加 GitHub Corners
- Python编程学习视频
- 4种免费将图片转成PDF的方法,手机电脑都能用