test cases for trie index
[csql.git] / test / jdbc / Connection / ConnTest4.java
blob077fe61728ca673ba83d7c2395d051543e7d5704
1 //Test 100 statements simultaneously in one connection , insert 1 tuple from
2 //each stmt, and check whether 100 tuples are inserted.
3 //Author: XieLiang
4 import java.sql.*;
5 public class ConnTest4
7 public static void main(String[] args)
9 try
11 Class.forName("csql.jdbc.JdbcSqlDriver");
12 Connection con = DriverManager.getConnection("jdbc:csql", "root", "manager");
13 Statement cStmt = con.createStatement();
14 int ret =0;
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);
23 int count =0;
24 for (int i=0; i <100 ; i++)
26 stmt[i].setInt(1, i);
27 stmt[i].setString(2, String.valueOf(i+100));
28 ret = stmt[i].executeUpdate();
29 if (ret != 1) break;
30 stmt[i].close();
31 con.commit();
32 count++;
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;");
38 count=0;
39 while (rs.next())
41 count++;
43 rs.close();
44 con.commit();
45 cStmt.execute("DROP TABLE T1;");
46 con.close();
47 if (count == 100) System.exit(0); else System.exit(1);
48 }catch(Exception e) {
49 System.out.println("Exception in Test: "+e);
50 e.printStackTrace();
51 System.exit(1);