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 ;
    }
                

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章