adding test scripts
[csql.git] / test / jdbc / Statement / TestScript12.java
blob32a530406c5460df95620cfa2f973531f682b65e
1 //execute with select,get result set and close the result set and then call fetch, it should fail
2 import java.sql.*;
3 /**
5 * @author praba
6 */
7 public class TestScript12 {
8 public static Connection con;
9 public static Statement cStmt;
10 public static void main(String[] args)
12 try
14 Class.forName("csql.jdbc.JdbcSqlDriver");
15 con = DriverManager.getConnection("jdbc:csql", "root", "manager");
16 cStmt = con.createStatement();
17 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 integer);");
18 con.commit();
19 PreparedStatement stmt = null, selStmt= null;
20 stmt = con.prepareStatement("INSERT INTO T1 VALUES (?,?);");
21 stmt.setInt(1, 1);
22 stmt.setInt(2,2);
23 stmt.executeUpdate();
24 stmt.close();
25 con.commit();
27 cStmt = con.createStatement();
28 cStmt.execute("SELECT * from T1;");
29 ResultSet rs=cStmt.getResultSet();
30 rs.next();
31 System.out.println("Record: " + rs.getInt(1)+ " "+ rs.getInt(2));
32 rs.close();
33 rs.next();
34 System.out.println("Failed:rs.next succedded");
35 con.commit();
36 con.close();
37 System.exit(1);
38 }catch(Exception e) {
39 System.out.println("Exception in Test: "+e);
40 e.printStackTrace();
41 try{
42 con.close();
43 }catch(Exception ex){}
44 System.exit(0);