1. 错误描述

在使用mysql时,如果数据库中的字段类型是timestamp,默认为0000-00-00,会发生异常:Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp.

2. 解决办法

给数据库的 jdbc.url 加上 zeroDateTimeBehavior 参数,如下:

jdbc.url=jdbc:mysql://127.0.0.1:3306/seckill?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=round

注意参数间不能有空格;否则报错 org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection

zeroDateTimeBehavior参数有两种配置:

  1. zeroDateTimeBehavior=round ,”0000-00-00“会默认转换为”0001-01-01 00:00:00”
  2. zeroDateTimeBehavior=convertToNull,“0000-00-00“会转换为null

MySQL 错误【四】Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp相关推荐

  1. 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 ...

  2. 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,默认为 ...

  3. 错误: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;刚开始 ...

  4. 已解决: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 ...

  5. 关于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 ...

  6. 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 分析: ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

最新文章

  1. 2008年 浙工大考研计算机专业课试题C++
  2. 每天一个linux命令(50):crontab命令
  3. python 学习 我推荐这本书,适合特别没有程序基础或者编程思维较差的人,
  4. 微服务系列实践 .NET CORE
  5. SprinBoot 集成 Flowable/Activiti工作流引擎
  6. 11-Docker Bridge详解
  7. Python打印某范围内的素数
  8. 鸿蒙系统深度解析,深度解析鸿蒙内核最重要的结构体
  9. Log4j2日志框架集成Slf4j日志门面
  10. centos 时区正确,时间不对
  11. 说服力:从场景化出发的用户价值
  12. java设计模式——adapter模式
  13. 1一10到时的英文单词_[1-10的英语单词读音]1到10的英语单词
  14. KDD cup 2017 高速公路收费站交通流量预测 中文翻译(转载)
  15. java中case怎么用,Java中case使用示例,Javacase使用示例,switch([vari
  16. jQuery手风琴图片轮播(源码+注释)
  17. 亲戚B (普通并查集)
  18. “南京才不相信互联网呢”
  19. python 怎么输出实际的根号2_Python怎么输出根式?
  20. BST、AVL、BTree、B+Tree、B*Tree、23Tree、234Tree、TTree、RBTree、LLRBTree、AATree、SplayTree、Treap、无旋Treap、scap

热门文章

  1. 绕过AMSI详细指南:如何利用DLL hijack轻松绕过AMSI
  2. 一次 WebResource.axd 异常处理经历
  3. 帷幄匠心 c++ qt岗位,一二三四面 2个半小时
  4. win7计算机管理无用户账户,win7系统控制面板中用户账户显示空白的解决方法
  5. 建博第一天。。。希望每天都有进步,,加油!!!如你的昵称!!!
  6. 解决:给 VSCode 手动添加(解压压缩包)相关插件的问题
  7. 雅诗兰黛中国创新研发中心在上海揭幕;安联贸易任命中国区行政总裁 | 美通企业日报...
  8. 【Hadoop】HDFS文件写入与文件读取过程
  9. Zigbee,esp8266(wifi),蓝牙协议三种通信方式
  10. KE-之单机案例分析