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), primary key(f1));");
12 System
.out
.println("Table t1 created");
16 PreparedStatement stmt
= null, selStmt
= null;
17 stmt
= con
.prepareStatement("INSERT INTO T1 (f1, f2) VALUES (?, ?);");
20 stmt
.setString(2, "DummyValue");
21 long start
=0, end
=0, curr
=0;
22 long min
=100000, max
=0, tot
=0;
23 for (int i
=0 ; i
<= 100 ; i
++) {
24 start
= System
.nanoTime();
26 stmt
.setString(2, "DummyValue");
27 ret
= stmt
.executeUpdate();
28 if (ret
!= 1) break; //error
29 end
= System
.nanoTime();
33 if (min
> curr
) min
= curr
;
34 if (max
< curr
) max
= curr
;
40 System
.out
.print("Insert : " + count
);
41 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
44 start
=0; end
=0; curr
=0;
45 min
=100000; max
=0;tot
=0;
46 selStmt
= con
.prepareStatement("SELECT * from T1 where f1 = ?;");
50 for (int i
=0 ; i
<= 100 ; i
++) {
51 start
= System
.nanoTime();
53 rs
= selStmt
.executeQuery();
56 intVal
= rs
.getInt(1);
57 strVal
= rs
.getString(2);
61 end
= System
.nanoTime();
63 //System.out.println("Tuple "+ intVal+ " "+ strVal);
66 if (min
> curr
) min
= curr
;
67 if (max
< curr
) max
= curr
;
72 System
.out
.print("Select : " + count
);
73 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
76 start
=0; end
=0; curr
=0;
77 min
=100000; max
=0;tot
=0;
78 stmt
= con
.prepareStatement("UPDATE T1 SET f2 = ? WHERE f1 = ?;");
79 for (int i
=0 ; i
<= 100 ; i
++) {
80 start
= System
.nanoTime();
82 stmt
.setString(1, "UpdatedValue");
83 ret
= stmt
.executeUpdate();
84 if (ret
!= 1) break; //error
85 end
= System
.nanoTime();
89 if (min
> curr
) min
= curr
;
90 if (max
< curr
) max
= curr
;
95 System
.out
.print("Update : " + count
);
96 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
99 start
=0; end
=0; curr
=0;
100 min
=100000; max
=0;tot
=0;
101 stmt
= con
.prepareStatement("DELETE FROM T1 WHERE f1 = ?;");
102 for (int i
=0 ; i
<= 100 ; i
++) {
103 start
= System
.nanoTime();
105 ret
= stmt
.executeUpdate();
106 if (ret
!= 1) break; //error
107 end
= System
.nanoTime();
111 if (min
> curr
) min
= curr
;
112 if (max
< curr
) max
= curr
;
117 System
.out
.print("Delete : " + count
);
118 System
.out
.println(" Min:" + min
+ " Max: "+max
+" Avg: "+ tot
/100 );
120 //cStmt.execute("DROP TABLE T1;");
121 System
.out
.println("Dropped table T1");
127 System
.out
.println("Exception in Test: "+e
);