adding test scripts
[csql.git] / test / jdbc / Statement / StmtTest3.java
blobe7b11c6ec0dbc8d32590ad541afa1a9fc7005e77
1 //close() and then execute INSERT/QUERY/UPDATE statement. It should fail
2 import java.sql.*;
3 public class StmtTest3
5 public static void main(String[] args)
7 try
9 Class.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con = DriverManager.getConnection("jdbc:csql", "root", "manager");
11 Statement cStmt = con.createStatement();
12 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
13 cStmt.execute("CREATE INDEX IDX ON T1 ( f1);");
14 con.commit();
15 con.close();
17 //after close the connection,execute "INSERT" statement,it should fail
18 try
20 cStmt.execute("INSERT INTO T1 VALUES (1, 'FIRST');");
21 System.exit(1);
23 catch(Exception e)
25 System.out.println("insert exception---" + e.getMessage());
28 //after close the connection,execute "QUERY" statement,it should fail
29 try
31 cStmt.executeQuery("SELECT * from T1 where f1 = 1;");
32 System.exit(2);
34 catch(Exception e)
36 System.out.println("query exception---" + e.getMessage());
39 //after close the connection,execute "UPDATE" statement,it should fail
40 try
42 cStmt.executeUpdate("UPDATE T1 SET f2 = 'CHANGED' WHERE f1 = 1;");
43 System.exit(3);
45 catch(Exception e)
47 System.out.println("update exception---" + e.getMessage());
50 //cleanup
51 cStmt.close();
52 Connection con1 = DriverManager.getConnection("jdbc:csql", "root", "manager");
53 Statement cStmt1 = con1.createStatement();
54 cStmt1.execute("DROP TABLE T1 ;");
55 cStmt1.close();
56 con1.close();
57 }catch(Exception e) {
58 System.out.println("Exception in Test: " + e.getMessage());
59 e.printStackTrace();
60 System.exit(4);