一、錯誤主題:
2020-02-07 22:37:43.596 ERROR 12612 --- [ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE t_film_info
SET modify_time = now()
WHERE
' at line 6
### The error may involve cn.changemax.dao.FilmInfoDAO.batchUpdate-Inline
### The error occurred while setting parameters
### SQL: UPDATE t_film_info SET modify_time = now() WHERE film_id = ? ; UPDATE t_film_info SET modify_time = now() WHERE film_id = ? ; UPDATE t_film_info SET modify_time = now() WHERE film_id = ? ; UPDATE t_film_info SET modify_time = now() WHERE film_id = ? t_film_info SET modify_time = now() WHERE film_id = ?
二、筆者發現什么代碼也沒改,突然sql執行錯誤了。還報語法錯誤,關鍵我還把這個sql拿去數據庫中執行了,反而執行成功了。
思慮再三發現:是在配置文件中關閉了一次執行多條sql的配置。
改為如下:
url: jdbc:mysql://127.0.0.1:3306/xxxxxxxxxxxx?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
核心在於參數:allowMultiQueries=true