jdbc 를 사용 하여 다 중 데이터 의 대량 삽입 데이터베이스(Oracle)

public boolean insertDetailed(List listDetailed){
        long start = System.currentTimeMillis();
        PreparedStatement pstmt=null;
        StringBuffer sql=new StringBuffer();
        int result=0;
        try {
            sql.append("insert INTO Detailed(id,DETAILNUMBER,payeebankname,payeebanknum,name,money,batchnumber,enterprisepipeliningnum,note,banknumber,status)");
            sql.append(" values");
            sql.append("(seq_detailed.nextval,?,?,?,?,?,?,?,?,?,?)");
            pstmt=getConnection().prepareStatement(sql.toString());
            for(int i = 0 ; i < listDetailed.size();i++){
                Detailed detailed = listDetailed.get(i);
                pstmt.setObject(1, detailed.getDetailnumber());//   DateUtil.get4yMdHms(new Date())
                pstmt.setObject(2, detailed.getPayeebankname());
                pstmt.setObject(3, detailed.getPayeebanknum());
                pstmt.setObject(4, detailed.getName());
                pstmt.setObject(5, detailed.getMoney());
                pstmt.setObject(6, detailed.getBatchnumber());
                pstmt.setObject(7, detailed.getEnterprisepipeliningnum());
                pstmt.setObject(8, detailed.getNote());
                pstmt.setObject(9, detailed.getBanknumber());
                pstmt.setObject(10, 0);
                pstmt.addBatch();
                if(i%500==0){
                    pstmt.executeBatch();
                }
            }
            pstmt.executeBatch();
//          getConnection().commit();
            long end = System.currentTimeMillis();
            System.out.println("        :"+(end - start)+"ms"); //        :24675
        } catch (Exception e) {
            LogUtil.saveLogSqlException(sql.toString(),e);
            e.printStackTrace();
        }finally{
            closeState(pstmt, rs);
        }
        return result>0?true:false;
    }

좋은 웹페이지 즐겨찾기