mybatis中想用 foreach标签 批量update set表
下面是mapper.xml

<update >
        <foreach collection="list" item="bean" index="index" open="" close="" separator=";">
            UPDATE dt_monitor
            <set>
                account_name = #{bean.companyAccount},
                sip_name = #{bean.sipName}
            </set>
            <where>
                company_id = #{bean.companyId}
            </where>
            ORDER BY update_time desc limit 1
        </foreach>
</update>

传入的List数量大于1的时候就报错。
后来发现是数据库配置的原因
在配置数据库连接地址中加上
&allowMultiQueries=true

jdbcDriver=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql:///cake?characterEncoding=utf-8&allowMultiQueries=true
jdbcusername=root
jdbcpassword=1

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2021-04-17
  • 2021-08-17
  • 2021-08-01
  • 2021-06-04
猜你喜欢
  • 2021-11-10
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-01-13
  • 2018-09-10
相关资源
相似解决方案