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