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