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