FileDocCategorySizeDatePackage
TestThinPerfPrepNR.javaAPI DocExample1613Tue Jul 31 20:52:00 BST 2001None

TestThinPerfPrepNR

public class TestThinPerfPrepNR extends Object

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

  int i;
  int n;
  long startTime; 
  long stopTime;

  n = Integer.parseInt(args[0]);
  String[] codes  = new String[n];
  String[] descrs = new String[n];
  for (i=0;i<n;i++) {
   byte[] bytes = new byte[30];
   for (int x=0;x<30;x++) {
    bytes[x] = (byte)((java.lang.Math.random() * 74) + 48);
   }
   codes[i] = new String(bytes);
  
   bytes = new byte[80];
   for (int x=0;x<80;x++) {
    bytes[x] = (byte)((java.lang.Math.random() * 74) + 48);
   }
   descrs[i] = new String(bytes);
  }

  DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
  Connection conn = 
   DriverManager.getConnection("jdbc:oracle:thin:@dssw2k01:1521:orcl","scott","tiger");
  conn.setAutoCommit(false);
  startTime = System.currentTimeMillis();
  PreparedStatement stmt = conn.prepareStatement(
   "insert into testxxxperf ( id, code, descr, insert_user, insert_date ) " +
   "values ( ?, ?, ?, USER, ? )");
  for (i=0;i<n;i++) {
   stmt.setInt(1,i);
   stmt.setString(2,codes[i]);
   stmt.setString(3,descrs[i]);
   stmt.setDate(4,new java.sql.Date(System.currentTimeMillis()));
   stmt.executeUpdate();
  }
  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 ) );