無法將“0000-00-00 00:00:00”轉換為TIMESTAMP
2017-05-08 00:56:59 [ERROR] - cn.kee.core.dao.impl.GeneralDaoImpl -GeneralDaoImpl.java(100) -GeneralDao getEntity with sql has failed! select * from user_base where userName = ? org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [ select * from user_base where userName = ? ]; Cannot convert value '0000-00-00 00:00:00' from column 14 to TIMESTAMP.; nested exception is java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 14 to TIMESTAMP.
我會在這里猜測你正在使用MySQL :-)它使用“零日期”作為特殊的占位符 - 不幸的是,JDBC默認情況下無法處理它們。
解決方案是將“zeroDateTimeBehavior = convertToNull”指定為MySQL連接的參數(在數據源URL或附加屬性中),例如:
jdbc:mysql://localhost/myDatabase?zeroDateTimeBehavior=convertToNull
這將導致所有這些值被檢索為NULL。