FileDocCategorySizeDatePackage
TestOCIPerfBatchN.javaAPI DocExample1444Mon Apr 23 18:43:42 BST 2001None

TestOCIPerfBatchN

public class TestOCIPerfBatchN extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

  int i;
  long startTime; 
  long stopTime;
  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  Connection conn = 
   DriverManager.getConnection("jdbc:oracle:oci8:@dssw2k01","scott","tiger");
  conn.setAutoCommit(false);
  System.out.println("Current Oracle default execute batch = " + ((oracle.jdbc.driver.OracleConnection)conn).getDefaultExecuteBatch());
  startTime = System.currentTimeMillis();
  PreparedStatement stmt = conn.prepareStatement(
   "insert into testxxxperf ( id, code, descr, insert_user, insert_date ) " +
   "values ( ?, ?, ?, ?, ? )");
  for (i=1;i<new Integer(args[0]).intValue()+1;i++) {
   stmt.setInt(1,i);
   stmt.setString(2,"123456789012345678901234567890");
   stmt.setString(3,"12345678901234567890123456789012345678901234567890123456789012345678901234567890");
   stmt.setString(4,"ZXVI01");
   stmt.setDate(5,new java.sql.Date(System.currentTimeMillis()));
   stmt.addBatch();
  }
  stmt.executeBatch();
  conn.commit(); 
  stopTime = System.currentTimeMillis();

  Statement dstmt = conn.createStatement();
  dstmt.executeUpdate("delete testxxxperf");
  conn.commit();
  dstmt.close();

  stmt.close();
  conn.close();
  System.out.println( "Elapsed time in milliseconds: " + Long.toString( stopTime - startTime ) );