• mysql date数据类型异常原因0000-00


    1.数据库字段:

    `dri_lic_first_time` date DEFAULT NULL COMMENT '驾驶证初次领证日期',

    2.异常信息

    org.springframework.dao.TransientDataAccessResourceException: 
    ### Error querying database.  Cause: java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
    ### The error may exist in com/autoyol/mapper/MemberMapper.xml
    ### The error may involve com.autoyol.mapper.MemberMapper.getMemBaseInfoByToken
    ### The error occurred while handling results
    ### SQL: SELECT reg_no as memNo, nick_name AS nickName, real_name AS realName, first_name AS firstName, gender, mobile,     base_dir AS userBasePath, portrait_path AS portrait, res_times AS ownerResTimes, res_total_time AS ownerResTotalTime,     res_avg_time AS ownerResAvgTime, buy_times AS rentTimes, buy_total_res_time AS renterResTotalTime,     buy_res_avg_time AS renterResAvgTime, email, email_auth AS emailAuth, id_card_auth,     id_card_back_auth, dri_lic_auth, day_req_count, day_cancel_req_count, rent_flag, renter_rating as renterRating ,dri_lic_first_time as driLicFirstTime    FROM member WHERE token=?
    ### Cause: java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp
    ; SQL []; Value '0000-00-00' can not be represented as java.sql.Timestamp; nested exception is java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Timestamp

    3.分析

    3.1在客户端修改数据为空,系统会默认加上'0000-00',这样在查询的时候,映射会报错,无法理解这个日期时间

    3.2如果要去掉日期数据,需要填写NULL,这样才可以。

    3.2直接选择日期或填写日期,2015-01-22

  • 相关阅读:
    MySQL教程22-字符串类型
    MySQL教程21-日期和时间类型
    MySQL教程20-小数类型
    MySQL教程19-整数类型
    MySQL教程18-数据类型简介
    ActiveMQ_topic
    ActiveMQ_消费者编码
    ActiveMQ_生产者编码
    ActiveMQ介绍
    管理docker容器
  • 原文地址:https://www.cnblogs.com/simpledev/p/4241718.html
Copyright © 2020-2023  润新知