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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。