IBATIS 批量添加

 
 public int batchInsert(final List<GroupVo> groupVoList){
  int flag = 0 ;
    try{
     this.getSqlMapClientTemplate().execute(
          new SqlMapClientCallback() {
                 public Object doInSqlMapClient(SqlMapExecutor executor) {  
                 try{
                     executor.startBatch();
                     for (GroupVo groupVo : groupVoList) {
                         executor.insert("addMobile", groupVo);
                     }           
                     executor.executeBatch();  
                    }catch(SQLException e){
                     e.printStackTrace();
                     log.error("检批量插入手机号码失败--SQL异常!", e);
                    }
                    return null  ;
              };
         }
     );
     flag = 1 ;
    }catch(Exception e){
     log.error("txt文件导入手机号码异常!", e);
     flag = 0 ;
    }
   
    return flag ;
    }
                

}

你可能感兴趣的:(sql,ibatis)