同步發布: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參數有兩種配置: