'addbatch'에 해당되는 글 1건

  1. 2007.03.19 [sampe] addBatch Query일괄실행
Query 한꺼번에 실행하는것 입니다.


  PoolManager pool = PoolManager.getInstance();
  Connection conn = null;
  PreparedStatement pstmt = null;
   
  try {
   conn = (Connection) pool.getConnection();  
   
pstmt = conn.prepareStatement("delete from neouserTable where name = ?");
   
   for (int i=0; i < daumid.length; i++) {  
    pstmt.setString (1, name[i]);
    pstmt.addBatch();
   }

 
   int results[] = pstmt.executeBatch();  
   returnValue ="true";
   
  } catch (BatchUpdateException e) {
      int rsSuccessCnts[] = e.getUpdateCounts();     //오류  발생 이전의 SQL 문에서 insert된 행 갯수를 배열로 리턴한다.
      for( int i=0; i<rsSuccessCnts.length; i++ ) {
       _logger.debug( i + "번째 쿼리 성공, 해당 쿼리에서 insert된 행 갯수: " + rsSuccessCnts[i] );
      }
      returnValue ="false";     
  } finally { PoolManager.close( pstmt, conn);}


1 

글 보관함

카운터

Total : / Today : / Yesterday :
get rsstistory!