zoukankan      html  css  js  c++  java
  • mybatis+sqlserver批量insert操作数据库报错:The server supports a maximum of 2100 parameters

     这篇博客与 上一篇(mybatis+sqlserver批量update操作数据库报错:The server supports a maximum of 2100 parameters) 的解决办法一样。

     1.  serverImpl里面。

    绿色框的items.size() ,可能超过2100,但是只要超过就会报错,所以也要这样处理。

     

    2. Mapper(也就是DAO层)里面

    3.     Mapper.xml里面

    <!-- 从sap读取生产订单 -->
        <insert id="createProductionOrderFromSap"
            parameterType="com.kent.qr.model.FormSapProductionOder"
            useGeneratedKeys="true" keyProperty="orderNo">
            insert into production_order(
            plant
            , production_order
            , order_type
            ,
            batch_no
            , customer_code
            ,customer_name
            , material_no
            , mode_no
            ,
            cust_material_no
            , order_qty
            , uom
            , packing_category
            , country
            , mpt
            , mpq
            , mpt_material_no
            , length
            , width
            , high
            , apt
            , apq
            , assortment_id
            ,
            assortment_description
            ,total_carton_qty
            , upload_time
            , rel_date
            , locco
            , airplane_type
            , zscxs
            , status
            , status_msg
            )values
            <foreach collection="items2" item="po" separator=",">
                (
                #{po.plant},
                #{po.productionOrderNo},
                #{po.orderType},
                #{po.batchNo},
                #{po.customerCode},
                #{po.customerName},
                #{po.materialNo},
                #{po.moldNo},
                #{po.custMaterialNo},
                #{po.orderQty},
                #{po.uom},
                #{po.packingCategory},
                #{po.country},
                #{po.mpt},
                #{po.mpq},
                #{po.mptMaterialNo},
                #{po.length},
                #{po.width},
                #{po.high},
                #{po.apt},
                #{po.apq},
                #{po.assortmentID},
                #{po.assortmentDescription},
                #{po.totalCartonQty},
                #{po.uploadTime},
                #{po.relDate},
                #{po.locco},
                #{po.airplaneType},
                #{po.zscxs},
                #{po.status},
                #{po.statusMsg}
                )
            </foreach>
        </insert>
  • 相关阅读:
    CVS,GIT,Mercurial和SVN比较
    ubuntu-使用终端配置网络
    编写简单的hashCode方法
    编写高质量equals方法
    文件上传和下载
    Java常用命令
    增删查改-MySQL
    Newton迭代法-C++
    二分法-C++
    适配器模式
  • 原文地址:https://www.cnblogs.com/PinkPink/p/13832902.html
Copyright © 2011-2022 走看看