Mybaits批量插入报错check the manual...

参考文章:https://blog.csdn.net/qq_44868502/article/details/104197565
Mybaits批量插入报错check the manual that corresponds to your MySQL server version for the right syntax

使用的是ruoyi框架,由于没有批插的方法,自己手写了个。xml如下

<update id="batchUpdateSupplierInfo">
       <foreach item="item" index="index" collection="list" open="" close="" separator="">
           update supplier_info
           <set>
               <if test="item.toElsAccount != null and item.toElsAccount!=''">
                   `to_els_account` = #{item.toElsAccount},
               </if>
               <if test="item.elsAccount != null and item.elsAccount!=''">
                   `els_account` = #{item.elsAccount},</if>
               <if test="item.supplierCode != null and item.supplierCode!=''">
                   `supplier_code` = #{item.supplierCode},
               </if>
               <if test="item.supplierName != null and item.supplierName!=''">
                   `supplier_name` = #{item.supplierName},
               </if>
               <if test="item.name != null and item.name!=''">
                   `name` = #{item.name},</if>
               <if test="item.creditCode != null and item.creditCode!=''">
                   `credit_code` = #{item.creditCode},</if>
               <if test="item.taxNumber != null and item.taxNumber!=''">
                   `tax_number` = #{item.taxNumber},</if>
               <if test="item.legalPersonName != null and item.legalPersonName!=''">
                   `legal_person_name` = #{item.legalPersonName},
               </if>
               <if test="item.creator != null and item.creator!=''">
                   `creator` = #{item.creator},</if>
               <if test="item.updater != null and item.updater!=''">
                   `updater` = #{item.updater},</if>
               <if test="item.createTime != null">
                   `create_time` = #{item.createTime},</if>
               <if test="item.updateTime != null">
                   `update_time` = #{item.updateTime},</if>
               <if test="item.rmk != null and item.rmk!=''">
                   `rmk` = #{item.rmk}</if>
           </set>
           where id = #{item.id};
       </foreach>
   </update>

外层使用List切片,没500条为一组,按组更新,防止单批sql太长
运行过程中一直报错:
check the manual that corresponds to your MySQL server version for the right syntax
但是同样的数据,每批一条执行又没有报错,只要每批多条就必报错,不胜其烦。

解决方案

数据库链接的url加入:allowMultiQueries=true
例如

jdbc:mysql://127.0.0.0:3306/test?characterEncoding=UTF-8&allowMultiQueries=true

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×