adding test scripts
[csql.git] / test / jdbc / Connection / ConnTest3.java
blobdafbcdab99a1f6aff9b59d6a3652ba05d7331634
1 //Test 5000 statements in one connection one after other
2 //Author: XieLiang
3 import java.sql.*;
4 public class ConnTest3
6 public static void main(String[] args)
8 try
10 Class.forName("csql.jdbc.JdbcSqlDriver");
11 Connection con = DriverManager.getConnection("jdbc:csql", "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 = null;
17 for (int i=0; i <5000 ; i++)
19 stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
20 stmt.setInt(1, i);
21 stmt.setString(2, String.valueOf(i+100));
22 ret = stmt.executeUpdate();
23 if (ret !=1) break;
24 stmt.close();
25 con.commit();
26 if (i %100 ==0)
28 System.out.println("Total statements created "+ i);
29 System.gc();
30 Thread.sleep(500);
35 cStmt = con.createStatement();
36 System.out.println("Listing tuples:");
37 ResultSet rs = cStmt.executeQuery("SELECT * from T1;");
38 int count =0;
39 while (rs.next())
41 count++;
43 System.out.println("Total rows selected " + count);
44 rs.close();
45 con.commit();
46 cStmt.execute("DROP TABLE T1;");
47 con.close();
48 if (count !=5000) System.exit(1); else System.exit(0);
49 }catch(Exception e) {
50 System.out.println("Exception in Test: "+e);
51 e.printStackTrace();
52 System.exit(1);