mysql-Cannot convert value '2020-02-17 17:00:56' from column 3 to TIMESTAMP,nanos > 999999999 or 0

Scenario: Convert the activiti workflow database from oracle to mysql, use List comlist = taskService.getTaskComments (task_id_); query ACT_HI_COMMENT historical information, when id_ is 6 digits (such as 100036), tomcat reports an error, less than 6 digits id_ will not report an error.

Insert picture description here

Page error message

Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘TIME_’ from result set. Cause: java.sql.SQLException: Cannot convert value ‘2020-02-17 17:00:56.000000’ from column 3 to TIMESTAMP. ### The error may exist in org/activiti/db/mapping/entity/Comment.xml ### The error may involve org.activiti.engine.impl.persistence.entity.CommentEntity.selectCommentsByTaskId ### The error occurred while handling results ### SQL: select * from ACT_HI_COMMENT where TASK_ID_ = ? and TYPE_ = ‘comment’ order by TIME_ desc ### Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘TIME_’ from result set. Cause: java.sql.SQLException: Cannot convert value ‘2020-02-17 17:00:56.000000’ from column 3 to TIMESTAMP.

Idea error message mainly contains 2 types
Cannot convert value '2020-02-17 17:00:56.000000' from column 3 to TIMESTAMP.
 
Caused by: java.lang.IllegalArgumentException: nanos > 999999999 or < 0

Approach

According to the error information, it can be seen that the data type conversion error. The version of the MySQL JDBC driver used in the project is mysql-connector-java-5.1.10-bin. After switching to the higher version mysql-connector-java-8.0.15.jar, the problem Successfully resolved.
Corresponding db.driverClassName = com.mysql.jdbc.Driver, should be changed com.mysql = db.driverClassName. CJ .jdbc.Driver.

Corresponding to Cannot convert value '0000-00-00 00:00:00' from column 1 to TIMESTAMP solution
If the date field value in the database is' 0000-00-00 00:00:00 "is invalid time
in jdbc : mysql: //127.0.0.1: 3306 / test? useUnicode = true & characterEncoding = UTF-8 followed by a parameter zeroDateTimeBehavior = convertToNull
that is changed to:
jdbc: mysql: //127.0.0.1: 3306 / test? useUnicode = true & characterEncoding = UTF-8 & zeroDateTimeBehavior = convertToNull

Published 19 original articles · Likes2 · Visits 721

Guess you like

Origin blog.csdn.net/qq_40977118/article/details/104363780