*** empty log message ***
[csql.git] / test / jdbc / Gateway / GwTest11.java
blobdb230e8b353437046798251f2c4c9ec178208776
2 //donot run csql server
3 //Create a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with no params statement.
4 import java.sql.*;
5 /**
7 * @author bijaya
8 */
9 public class GwTest11 {
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();
19 cStmt.execute("INSERT INTO t1 VALUES (1, 'FIRST');");
20 cStmt.executeUpdate("INSERT INTO t1 VALUES (2, 'SECOND');");
21 con.commit();
23 ResultSet rs = null;
24 rs = cStmt.executeQuery("SELECT * from t1 where f1 = 1;");
25 while (rs.next())
27 System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2));
29 rs.close();
32 cStmt.execute("SELECT * from t1 where f1 = 2;");
33 rs = cStmt.getResultSet();
34 while (rs.next())
36 System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2));
38 rs.close();
39 con.commit();
41 cStmt.executeUpdate("UPDATE t1 SET f2 = 'CHANGED' WHERE f1 = 1;");
42 con.commit();
46 cStmt.executeUpdate("DELETE FROM t1 WHERE f1 = 2;");
47 con.commit();
49 System.out.println("After delete, listing tuples:");
50 rs = cStmt.executeQuery("SELECT * from t1 ;");
51 while (rs.next())
53 System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2));
55 rs.close();
56 con.close();
57 }catch(Exception e) {
58 System.out.println("Exception in Test: "+e);
59 e.printStackTrace();