adding test scripts
[csql.git] / test / jdbc / Connection / ConnTest5.java
blobeb19cc8c88f2bd793e03200b0c1fee27dca02e84
1 //Test 100 statements, inserting 1 tuple, committed in 1 transaction, check whether total tuples is 100
2 //Author: XieLiang
3 import java.sql.*;
4 public class ConnTest5
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[] = new PreparedStatement[100];
17 for (int i=0; i <100 ; i++)
19 stmt[i] = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
20 if (i %10 ==0) System.out.println("statements prepared "+ i);
22 for (int i=0; i <100 ; i++)
24 stmt[i].setInt(1, i);
25 stmt[i].setString(2, String.valueOf(i+100));
26 ret = stmt[i].executeUpdate();
27 if (ret != 1) break;
28 stmt[i].close();
30 con.commit();
32 cStmt = con.createStatement();
33 System.out.println("Listing tuples:");
34 ResultSet rs = cStmt.executeQuery("SELECT * from T1;");
35 int count =0;
36 while (rs.next())
38 count++;
40 rs.close();
41 con.commit();
42 cStmt.execute("DROP TABLE T1;");
43 con.close();
44 if (count == 100) System.exit(0); else System.exit(1);
45 }catch(Exception e) {
46 System.out.println("Exception in Test: "+e);
47 e.printStackTrace();
48 System.exit(1);