Caused by: java.sql.SQLException: HOUR_OF_DAY: 2 -> 3
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85)
at com.mysql.cj.jdbc.result.ResultSetImpl.getTimestamp(ResultSetImpl.java:923)
at com.mysql.cj.jdbc.result.ResultSetImpl.getTimestamp(ResultSetImpl.java:968)
at com.alibaba.druid.pool.DruidPooledResultSet.getTimestamp(DruidPooledResultSet.java:366)
at com.taobao.tddl.jdbc.druid.jdbc.TResultSetWrapper.getTimestamp(TResultSetWrapper.java:318)
at com.taobao.tddl.client.jdbc.resultset.newImp.ProxyTResultSet.getTimestamp(ProxyTResultSet.java:390)
at sun.reflect.GeneratedMethodAccessor162.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.ResultSetLogger.invoke(ResultSetLogger.java:69)
at com.sun.proxy.$Proxy177.getTimestamp(Unknown Source)
at org.apache.ibatis.type.DateTypeHandler.getNullableResult(DateTypeHandler.java:39)
at org.apache.ibatis.type.DateTypeHandler.getNullableResult(DateTypeHandler.java:28)
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:81)
我的环境:服务器,mysql都是东八区。使用的springboot2.X,DB中字段类型是timestamp 解决办法:
1. mysql-connector-java.jar版本6.x、8.x降级为5.1.x
2. 对于高版本jdbc,连接串强制指定时区参数:serverTimezone=GMT%2B8
3. 对于高版本jdbc,mysql数据库强制修改time_zone为“+8:00”,而非“SYSTEM
注意:本文归作者所有,未经作者允许,不得转载