adding test scripts
[csql.git] / test / jdbc / Connection / ConnTest27.java
blobaf207a14f53ebbd6fe5356701e782f7e1ed43169
1 //Create Connection, call rollback() 10K times.
2 //System should be stable, check this by creating new connection and insert 1 tuple.
3 //Author: XieLiang
4 import java.sql.*;
5 public class ConnTest27
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 con.setAutoCommit(false);
14 Statement cStmt = con.createStatement();
15 int ret = 0;
16 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
17 con.commit();
18 for (int i=0; i <10000; i++)
19 con.rollback();
20 con.close();
21 Connection con2 = DriverManager.getConnection("jdbc:csql","root","manager");
22 int count = 0;
23 cStmt = con2.createStatement();
24 PreparedStatement stmt = null;
25 stmt = con2.prepareStatement("INSERT INTO T1 VALUES (?,?);");
26 stmt.setInt(1,1);
27 stmt.setString(2,"test1");
28 ret = stmt.executeUpdate();
29 if (ret != 1)
30 System.out.println("test failed!");
31 stmt.close();
32 ResultSet rs = cStmt.executeQuery("SELECT * from T1;");
33 while(rs.next())
35 count++;
37 rs.close();
38 System.out.println("Total rows selected " + count);
39 cStmt.execute("DROP TABLE T1;");
40 con2.close();
41 if (count ==1) System.exit(0); else System.exit(1);
42 }catch(Exception e) {
43 System.out.println("Exception in Test: "+e);
44 e.printStackTrace();
45 System.exit(1);