2 public class JDBCExecTest
4 public static void main(String
[] args
)
8 Class
.forName("csql.jdbc.JdbcSqlDriver");
9 Connection con
= DriverManager
.getConnection("jdbc:csql", "root", "manager");
10 Statement cStmt
= con
.createStatement();
11 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (194));");
12 System
.out
.println("Table t1 created");
13 cStmt
.execute("CREATE INDEX IDX ON T1 (f1) ;");
14 System
.out
.println("Primary Index created on T1 (f1) ");
18 Statement stmt
= con
.createStatement();
19 String sql
= "INSERT INTO T1 (f1, f2) VALUES (1, 'DummyValue');";
22 long start
=0, end
=0, curr
=0;
23 long min
=100000, max
=0, tot
=0;
24 for (int i
=0 ; i
<= 100 ; i
++) {
25 start
= System
.nanoTime();
26 ret
= stmt
.executeUpdate(sql
);
27 if (ret
!= 1) break; //error
28 end
= System
.nanoTime();
32 if (min
> curr
) min
= curr
;
33 if (max
< curr
) max
= curr
;
38 System
.out
.println("Total Rows inserted " + count
);
39 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
42 start
=0; end
=0; curr
=0;
43 min
=100000; max
=0;tot
=0;
44 sql
= "SELECT * from T1 where f1 = 6;";
48 for (int i
=0 ; i
<= 100 ; i
++) {
49 start
= System
.nanoTime();
50 rs
= stmt
.executeQuery(sql
);
56 end
= System
.nanoTime();
60 if (min
> curr
) min
= curr
;
61 if (max
< curr
) max
= curr
;
65 System
.out
.println("Total Rows selected " + count
);
66 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
69 cStmt
.execute("DROP TABLE T1;");
70 System
.out
.println("Dropped table T1");
76 System
.out
.println("Exception in Test: "+e
);