jdbcTemplate批量插入

public boolean insertShopsInfo(List<Shops> list){
        final List<Shops> shopsList = list;
        String sql="INSERT INTO WEBSITE_MALL (NAME,HIGHT,MALL_INFO,OPRATION_BTIME ,OPRATION_ETIME,BELONG_TO,ADDRESS,VECTOR,FLOOR,FLOOR_IFNO,REMARK,UPDATE_DATE) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
        this.getJdbcTemplate().batchUpdate(sql, new BatchPreparedStatementSetter(){
            public void setValues(PreparedStatement ps,int i)throws SQLException
               {
                String name=shopsList.get(i).getName();
                String hight = shopsList.get(i).getHight();
                String mall_info = shopsList.get(i).getMall_info();
                Date opration_btime = shopsList.get(i).getOpration_btime();
                Date opration_etime = shopsList.get(i).getOpration_etime();
                String belong_to = shopsList.get(i).getBelong_to();
                String address = shopsList.get(i).getAddress();
                String vector = shopsList.get(i).getVector();
                String floor = shopsList.get(i).getFloor();
                String floor_ifno = shopsList.get(i).getFloor_ifno();
                String remark = shopsList.get(i).getRemark();
                Date update_date = shopsList.get(i).getUpdate_date();
                ps.setString(1, name);
                ps.setString(2, hight);
                ps.setString(2, mall_info);
                ps.setDate(4, (java.sql.Date)opration_btime);
                ps.setDate(5, (java.sql.Date)opration_etime);
                ps.setString(6, belong_to);
                ps.setString(7, address);
                ps.setString(8, vector);
                ps.setString(9, floor);
                ps.setString(10, floor_ifno);
                ps.setString(11, remark);
                ps.setDate(12, (java.sql.Date)update_date);
               }
               public int getBatchSize()
               {
                return shopsList.size();
               }
        });
        
        return true;
    }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值