1 //Create a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with no params statement.
5 public static void main(String
[] args
)
9 Class
.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con
= DriverManager
.getConnection("jdbc:csql://localhost:5678/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);");
16 cStmt
.execute("INSERT INTO T1 VALUES (1, 'FIRST');");
17 cStmt
.executeUpdate("INSERT INTO T1 VALUES (2, 'SECOND');");
21 rs
= cStmt
.executeQuery("SELECT * from T1 where f1 = 1;");
24 System
.out
.println("Tuple value is " + rs
.getInt(1)+ " "+ rs
.getString(2));
29 cStmt
.execute("SELECT * from T1 where f1 = 2;");
30 rs
= cStmt
.getResultSet();
33 System
.out
.println("Tuple value is " + rs
.getInt(1)+ " "+ rs
.getString(2));
38 cStmt
.executeUpdate("UPDATE T1 SET f2 = 'CHANGED' WHERE f1 = 1;");
43 cStmt
.executeUpdate("DELETE FROM T1 WHERE f1 = 2;");
46 System
.out
.println("After delete, listing tuples:");
47 rs
= cStmt
.executeQuery("SELECT * from T1 ;");
50 System
.out
.println("Tuple value is " + rs
.getInt(1)+ " "+ rs
.getString(2));
54 cStmt
.execute("DROP TABLE T1 ;");
57 System
.out
.println("Exception in Test: "+e
);