• mybatis- spring 批量实现数据导入数据库


    终于实现了ibatis的批量插入,此方法插入3000条数据,比单条插入可以节省一半的时间
    XML代码:

    <insert id="insertBatch" parameterType="ArrayList">
    insert intouser(id,account,password,active,status,name,gender,active_date,expiry_date,type,remark,group_id,disable,exam_number,mobile)
    values
    <foreach collection="list"item="obj" index="index"separator="," >
    (#{obj.id},#{obj.account},#{obj.password},#{obj.active},#{obj.status},#{obj.name},#{obj.gender},#{obj.active_date},
    #{obj.expiry_date},#{obj.type},#{obj.remark},#{obj.group_id},#{obj.disable},#{obj.exam_number},#{obj.mobile})
    </foreach>
    </insert>

    在java中只需要传递list过来就可以了。
    我是这样写的:

    private ArrayList<Map<String, String>>userList = new ArrayList<Map<String,String>>();
    
    Map<String,String>userMap= new HashMap<String,String>();
    userMap.put("id", userId);
    userMap.put("account", arr[0]);
    userMap.put("password", pas);
    userMap.put("active", String.valueOf(1));
    userMap.put("status", String.valueOf(1));
    userMap.put("name", arr[1]);
    userMap.put("gender", String.valueOf(gender));
    userMap.put("active_date", active_date);
    userMap.put("expiry_date", expiry_date);
    userMap.put("type", String.valueOf(3));
    userMap.put("remark", null);
    userMap.put("group_id", String.valueOf(1));
    userMap.put("disable", String.valueOf(0));
    userMap.put("Exam_number", arr[15]);
    userMap.put("phoneNumber", arr[14]);
    userList.add(userMap);

    通过循环将数据加入到list,最后将list传递。

  • 相关阅读:
    SAE/ISO standards for Automotive
    The J1850 Core
    SAE J1708 DS36277 MAX3444, DS75176B
    X431 元征诊断枪
    凯尔卡C68全球版汽车电脑诊断仪
    汽车王牌
    Vehicle’s communication protocol
    Vehicle Network Protocols -- ISO/KWP CAN CCD PCI SCI / SCP / Class 2
    On-board diagnostics -- Standards documents
    On-board diagnostics connector SAE J1962
  • 原文地址:https://www.cnblogs.com/Lxiaojiang/p/6233442.html
Copyright © 2020-2023  润新知