import oracle.jdbc.driver.*;
import java.text.*;
import java.sql.*;
class TestThinPerfTypes {
public static void main (String args[]) throws SQLException {
int i;
long startTime;
long stopTime;
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@devdb02:1521:ohsdb","zxvi01","donaldj8");
Statement stmt = conn.createStatement();
((OracleStatement)stmt).defineColumnType(1, Types.INTEGER);
((OracleStatement)stmt).defineColumnType(2, Types.VARCHAR);
((OracleStatement)stmt).defineColumnType(3, Types.VARCHAR);
((OracleStatement)stmt).defineColumnType(4, Types.VARCHAR);
((OracleStatement)stmt).defineColumnType(5, Types.TIMESTAMP);
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMddHHmmss" );
conn.setAutoCommit(false);
startTime = System.currentTimeMillis();
for (i=1;i<1001;i++) {
stmt.executeUpdate("insert into oehr.testxxxperf ( id, code, descr, insert_user, insert_date ) " +
"values ( " + Integer.toString( i ) + ", '123456789012345678901234567890', " +
"'12345678901234567890123456789012345678901234567890123456789012345678901234567890', " +
"USER, to_date('" + sdf.format(new java.util.Date(System.currentTimeMillis())) + "', 'YYYYMMDDHH24MISS'))");
}
conn.commit();
stopTime = System.currentTimeMillis();
Statement dstmt = conn.createStatement();
dstmt.executeUpdate("delete oehr.testxxxperf");
conn.commit();
dstmt.close();
stmt.close();
conn.close();
System.out.println( "Elapsed time in milliseconds: " + Long.toString( stopTime - startTime ) );
}
} |