adding test scripts
[csql.git] / test / jdbc / Gateway / GwStmt3.java
blob6d8625053dfe0c516427a0728c076bf2a47491b8
1 //Cache table t1
2 //Open a connection and then close it. After that execute INSERT/QUERY/UPDATE statement. It should fail
4 import java.sql.*;
5 /**
7 * @author bijaya
8 */
9 public class GwStmt3 {
10 public static void main(String[] args)
12 try
14 Class.forName("csql.jdbc.JdbcSqlDriver");
15 Connection con = DriverManager.getConnection("jdbc:gateway", "root", "manager");
16 Statement cStmt = con.createStatement();
17 con.commit();
18 con.close();
20 //after close the connection,execute "INSERT" statement,it should fail
21 try
23 cStmt.execute("INSERT INTO t1 VALUES (1, 'FIRST');");
24 System.exit(1);
26 catch(Exception e)
28 System.out.println("insert exception---" + e.getMessage());
31 //after close the connection,execute "QUERY" statement,it should fail
32 try
34 cStmt.executeQuery("SELECT * from t1 where f1 = 1;");
35 System.exit(2);
37 catch(Exception e)
39 System.out.println("query exception---" + e.getMessage());
42 //after close the connection,execute "UPDATE" statement,it should fail
43 try
45 cStmt.executeUpdate("UPDATE t1 SET f2 = 'CHANGED' WHERE f1 = 1;");
46 System.exit(3);
48 catch(Exception e)
50 System.out.println("update exception---" + e.getMessage());
53 //cleanup
55 }catch(Exception e) {
56 System.out.println("Exception in Test: " + e.getMessage());
57 e.printStackTrace();
58 System.exit(4);