adding test scripts
[csql.git] / test / jdbc / network / Connection / ConnTest22.java
blobc64ca74113016bb8bf384f164d01ce56e8b864bf
1 //Create connection, setAutocommit(false) , create Statement, insert 10 tuples, close the connection.
2 //Open another connection and check the number of tuples. It should be Zero.
3 import java.sql.*;
4 public class ConnTest22
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();
15 int ret = 0;
16 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
17 PreparedStatement stmt = null;
18 stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
19 for (int i=0; i <10 ; i++)
21 stmt.setInt(1, i);
22 stmt.setString(2, String.valueOf(i));
23 ret = stmt.executeUpdate();
24 if (ret !=1) break;
26 stmt.close();
27 con.close();
28 con = DriverManager.getConnection("jdbc:csql","root","manager");
29 int count = 0;
30 cStmt = con.createStatement();
31 ResultSet rs = cStmt.executeQuery("SELECT * from T1;");
32 while(rs.next())
34 count++;
36 rs.close();
37 cStmt.execute("DROP TABLE T1;");
38 con.close();
39 if (count == 0) 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);