批量更新SQL配置:
<update id="batchdelByIds">
<foreach collection="creationIds" index="key" item="item" separator=";">
update creation set del_flag='1',update_time = NOW() where id=#{item}
</foreach>
</update>
更新接口报错:
{
"code": 500,
"message": "\r\n### 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 creation set del_flag='1',update_time = NOW() where id=5 and us' at line 3\r\n### The error may exist in file [F:\\workspace\\-provider\\creation\\target\\classes\\mapper\\CreationMapper.xml]\r\n### The error may involve defaultParameterMap\r\n### The error occurred while setting parameters\r\n### SQL: update tcreation set del_flag='1',update_time = NOW() where id=? and user_id=? ; update creation set del_flag='1',update_time = NOW() where id=? and user_id=?\r\n### 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 creation set del_flag='1',update_time = NOW() where id=5 and us' at line 3\n; bad SQL grammar []",
"serverTimeMillis": 1706858404166
}
解决方案:
数据库的连接url加上“&allowMultiQueries=true”

文章讲述了在尝试批量更新SQL配置时遇到的语法错误,解决方案是在数据库连接URL中添加`allowMultiQueries=true`,以解决MySQL服务器版本的SQL语法问题。

1758





