1 //Test 100 statements simultaneously in one connection , insert 1 tuple from
2 //each stmt, and check whether 100 tuples are inserted.
7 public static void main(String
[] args
)
11 Class
.forName("csql.jdbc.JdbcSqlDriver");
12 Connection con
= DriverManager
.getConnection("jdbc:csql", "root", "manager");
13 Statement cStmt
= con
.createStatement();
15 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
17 PreparedStatement stmt
[] = new PreparedStatement
[100];;
18 for (int i
=0; i
<100 ; i
++)
20 stmt
[i
] = con
.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
21 if (i
%10 ==0) System
.out
.println("statements prepared "+ i
);
24 for (int i
=0; i
<100 ; i
++)
27 stmt
[i
].setString(2, String
.valueOf(i
+100));
28 ret
= stmt
[i
].executeUpdate();
34 System
.out
.println("Total rows inserted "+ count
);
35 cStmt
= con
.createStatement();
36 System
.out
.println("Listing tuples:");
37 ResultSet rs
= cStmt
.executeQuery("SELECT * from T1;");
45 cStmt
.execute("DROP TABLE T1;");
47 if (count
== 100) System
.exit(0); else System
.exit(1);
49 System
.out
.println("Exception in Test: "+e
);