Mysql批量更新&allowMultiQueries=true允许批量更新

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

批量更新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

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值