zoukankan      html  css  js  c++  java
  • 000000-00-00 00:00:00x00' can not be represented as java.sql.Timestamp

    splunk日志报错:

    020-07-13 12:16:42,135 [INFO ] tomcat-threads--932(com.bill99.otter.api.customer.CustomerRegisterBandApi.customerRegister:99) - 用户注册异常,异常信息:{}.
    org.springframework.dao.TransientDataAccessResourceException: Error attempting to get column 'lastup_date' from result set.  Cause: java.sql.SQLException: Value '4699045402663510210666052x00x00registerAccountGetMemberCode注册会员编号接口x00x0012019-06-09 18:48:000000-00-00 00:00:00x00' can not be represented as java.sql.Timestamp
    ; SQL []; Value '4699045402663510210666052x00x00registerAccountGetMemberCode注册会员编号接口x00x0012019-06-09 18:48:000000-00-00 00:00:00x00' can not be represented as java.sql.Timestamp; nested exception is java.sql.SQLException: Value '4699045402663510210666052x00x00registerAccountGetMemberCode注册会员编号接口x00x0012019-06-09 18:48:000000-00-00 00:00:00x00' can not be represented as java.sql.Timestamp
    	at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:106) ~[spring-jdbc.jar:3.2.18.RELEASE]
    原因:建表语句设置字段值NOT NULL,插入数据时mysql自动插入“0000-00-00 00:00:00”,这样的字符串spring认为不是时间格式,导致报错。

    会产生“0000-00-00 00:00:00”的表结构:

    CREATE TABLE `t_terminalFunction_info` (
      `id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
      `create_date` datetime NOT NULL COMMENT '创建时间',
      `lastup_date` datetime NOT NULL COMMENT '更新时间'
    ) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=utf8 COMMENT='终端功能配置信息表'

    不会产生“0000-00-00 00:00:00”的表结构:

    CREATE TABLE `t_cp_config` (
      `SEQUENCE_ID` bigint(12) NOT NULL AUTO_INCREMENT COMMENT '主键',
      `CREATE_DATE` datetime DEFAULT NULL COMMENT '创建时间',
      `UPDATE_DATE` datetime DEFAULT NULL COMMENT '更新时间'
    ) ENGINE=InnoDB AUTO_INCREMENT=789561 DEFAULT CHARSET=utf8 COMMENT='自动开通配置表'

     解决方法:

    1、修改表结构,由于会锁表,必须在业务低峰时修改。

    2、修复历史数据,“0000-00-00 00:00:00”全部改为NULL

    坚持每天进步,自律改变自己
  • 相关阅读:
    浏览器跨域访问WebApi
    外部主机无法访问IIS发布的网站
    在VisualStudio中远程调试IIS站点
    关于跨域请求的一些解决方案
    MVC与WebApi中的异常过滤器
    委托与事件
    C#中的属性
    C#中的索引
    Equals与==的区别
    关于跨域响应头Access-Control-Allow-Headers的一些说明
  • 原文地址:https://www.cnblogs.com/seakyfly/p/13299023.html
Copyright © 2011-2022 走看看