解決數據庫時間字段沒法被描述

報錯爲:value XXXX can not be represented as java.sql.Timestamp ......
java

是由於數據庫中有 0000-00-00 00:00:00 這樣的值,這個值在MySQL中做爲一個特殊的存在,mysql

在Java中,java.sql.Date 會視爲不合法,被JVM認爲格式不正確。web

解決方法sql

鏈接數據庫的配置文件中加入zeroDateTimeBehavior=convertToNull數據庫


例如 在 web.properties 中 jdbc.url_conf 中ide

jdbc.url_conf=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNullurl

最後添加&zeroDateTimeBehavior=convertToNullspa

相關文章
相關標籤/搜索