mybatis sql错误语句

你珂哥 2019-10-16 03:16:41
<!-- 批量更新 -->
<update id="updateAll" parameterType="java.util.List">
<foreach item="item" index="index" collection="list" separator=";" >
update sys_settings
set SETTINGS_VALUE = #{item.value}
where SETTINGS_KEY = #{item.key}
</foreach>
</update>
运行报错
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 sys_settings
set SETTINGS_VALUE = '60667'
where SETTINGS_KEY = 'Int' at line 5
---------------------------------------------------------------
就语法错误,请教一下错误在哪里
...全文
144 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
你珂哥 2019-10-17
  • 打赏
  • 举报
回复
&allowMultiQueries=true
_Ricky_ 2019-10-16
  • 打赏
  • 举报
回复
在结尾加 “ ; ”,你在写多条sql一起运行,不用分号结尾会报错,还有就是不建议在mybatis这样循环sql语句,可以通过java循环修改,这样后面如果要改也方便
编程写手 2019-10-16
  • 打赏
  • 举报
回复
引用 3 楼 你珂哥的回复:
方法要想成功,需要在db链接url后面带一个参数 &allowMultiQueries=true 即: jdbc:mysql://localhost:3306/mysqlTest?characterEncoding=utf-8&allowMultiQueries=true 其实这种东西写过来写过去就是差不多一样的代码,不做重复的赘述,直接上代码。
编程写手 2019-10-16
  • 打赏
  • 举报
回复
应该是不能以;结尾导致的,mybatis可能不支持。
你珂哥 2019-10-16
  • 打赏
  • 举报
回复
你珂哥 2019-10-16
  • 打赏
  • 举报
回复
有没有大佬帮忙看一下啊

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧