adding test scripts
[csql.git] / test / jdbc / Connection / ConnTest26.java
blobfb45407735e20eeb9550dc27d522af648a9ef0ed
1 //Create Connection, call commit() 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 ConnTest26
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 for (int i=0; i <10000; i++)
18 con.commit();
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);