同步发布:http://www.yuanrengu.com/index.php/mysqlsolvetimestamp.html

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

解决办法如下:

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

jdbc.url=jdbc:mysql://localhost:3306/table?characterEncoding=UTF-8&zeroDateTimeBehavior=round

 zeroDateTimeBehavior参数有两种配置:

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

mysql解决Value ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp的更多相关文章

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

  2. java.sql.SQLException: 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 0 ...

  3. '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error

    '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error 异常现象 ### Cause: java.sql.SQ ...

  4. Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

    错误信息如下: Caused by: java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java ...

  5. 报错 java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp 原因

    sql异常 java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestam ...

  6. 报错:java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

    感谢原文作者:风起云淡- 原文链接:https://blog.csdn.net/shenguan777/article/details/78615521 异常分析: 在使用MySql时,如果数据库中有 ...

  7. JEECG中出现Java.sql.SQLException: Value 'xxxx' can not be represented as java.sql.Timestamp的解决办法

    出现`Java.sql.SQLException: Value 'xxxx' can not be represented as java.sql.Timestamp',其中xxxx部分对应包含一个看 ...

  8. Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

    1.问题场景描述:后台方法中执行查询返回list列表中,执行后台产生运行时异常 java.sql.SQLException: 2.问题排查和解决:排查代码,无编译时错误,断点调试,更具控制台找到对应的 ...

  9. 解决 SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp的问题

    连接数据库时 设置:zeroDateTimeBehavior=convertToNull

随机推荐

  1. js中的事件部分总结

    一.HTML事件 HTML事件处理就是直接在HTML标签上添加事件,举例 <p class="" onclick=function(){alert(HTML事件)}>& ...

  2. Oracle监听器启动出错:本地计算机上的OracleOraDb11g_home1TNSListener服务启动后又停止了解决方案

    一.错误描述 登陆PL/SQL Developer登陆本地数据库时先报没有监听程序,查看服务发现Oracle监听服务没有启动.右击启动监听程序,报错: 错误描述:本地计算机上的OracleOraDb1 ...

  3. eclipse控制台中文乱码解决方法

    一.全局设置 1.Window > Preferences 2.General > Workspace > Text file encoding. 3.选择 Other 4.手工输入 ...

  4. 电脑用miniDP链接显示器后电脑没声音

    今天用笔记本T440s miniDP 链接戴尔U2515显示器的 DP 连接后发现笔记本没声音了 原因: miniDP 不仅能支持视频传输还支持音频, 所以声音就改为从显示器发出了 但是我想让电脑输出 ...

  5. C#编程语言与面向对象—— 多态

    多态编程的基本原理是: 使用基类或接口变量编程. 在多态编程中,基类一般都是抽象类,其中拥有一个或多个抽象方法,各个子类可以根据需要重写这些方法.或者使用接口,每个接口都规定了一个或多个抽象方法,实现 ...

  6. Spring JdbcTemplate方法详解

    JdbcTemplate主要提供以下五类方法: execute方法:可以用于执行任何SQL语句,一般用于执行DDL语句: update方法及batchUpdate方法:update方法用于执行新增.修 ...

  7. kernel/dma.c

    /* $Id: dma.c,v 1.5 1992/11/18 02:49:05 root Exp root $ * linux/kernel/dma.c: A DMA channel allocato ...

  8. ✡ leetcode 170. Two Sum III - Data structure design 设计two sum模式 --------- java

    Design and implement a TwoSum class. It should support the following operations: add and find. add - ...

  9. echo '<script>alert("插入成功")</script>';

    echo '<script>alert("插入成功")</script>'; <?php if ( ! defined('BASEPATH')) ex ...

  10. Python检测IP合法 是否为公网IP

    判断IP 格式是否正确 def check_value(self, ipaddr): '''检查IP是否合法 :param ipaddr: string :return True ''' addr=i ...