FileDocCategorySizeDatePackage
TestThinPerfNR.javaAPI DocExample1680Tue Jul 31 20:35:36 BST 2001None

TestThinPerfNR.java

import java.text.*;
import java.sql.*;
class TestThinPerfNR {
 public static void main (String args[]) throws SQLException {
  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");
  Statement stmt = conn.createStatement();
  SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmss" );
  conn.setAutoCommit(false);

  startTime = System.currentTimeMillis();
  for (i=0;i<n;i++) {
   stmt.executeUpdate("insert into testxxxperf ( id, code, descr, insert_user, insert_date ) " +
    "values ( " + Integer.toString( i ) + ", '" + codes[i] + "', '" + descrs[i] + "', " +
    "USER, to_date('" + sdf.format(new java.util.Date(System.currentTimeMillis())) + "', 'YYYYMMDDHH24MISS'))");
  }
  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 ) );
 }
}