mysql批量更新 bad SQL grammar [] 错误

出现的问题

### The error occurred while setting parameters
### SQL: update crawler_ip_all                  SET auto_table = ?,                       put_reason = ?,                       put_user = ?,                       put_way = ?,                       createtime = ?,                       updtime = ?                   WHERE ip = ?               ;                  update crawler_ip_all                  SET auto_table = ?,                       put_reason = ?,                       put_user = ?,                       put_way = ?,                       createtime = ?,                       updtime = ?                   WHERE ip = ?
### 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 crawler_ip_all
                 SET auto_table = '1', 
                  ' at line 10
; bad SQL grammar []; nested exception is 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 crawler_ip_all
                 SET auto_table = '1', 
                  ' at line 10

mybatis 批量更新数据库的mapper

 <update id="updateBath" parameterType="java.util.List">
        <if test="list!=null">
            <foreach collection="list" item="item" index= "index" open="" close="" separator =";">
                update crawler_ip_all
                <set>
                    <if test ='null != item.autoTable'> auto_table = #{item.autoTable}, </if>
                    <if test ='null != item.putReason'> put_reason = #{item.putReason}, </if>
                    <if test ='null != item.putUser'> put_user = #{item.putUser}, </if>
                    <if test ='null != item.putWay'> put_way = #{item.putWay}, </if>
                    <if test ='null != item.createtime'> createtime = #{item.createtime}, </if>
                    <if test ='null != item.updtime'> updtime = #{item.updtime} </if>
                </set>
                <where>
                    ip = #{item.ip}
                </where>
            </foreach>
        </if>
    </update>

dao封装的接口

    int updateBath(@Param("list") List<CrawlerIPAllDetailBean> crawlerIPAllDetailBeanList);

最后的解决方案是:

的 url上 增加 allowMultiQueries=true 表示允许批量操作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值