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