1 //Create Connection, setAutocommit(true), create table t1, insert into t1 10 records
2 //then call rollback(), select and count the number of records. It should be 10
4 public class ConnTest34
6 public static void main(String
[] args
)
10 Class
.forName("csql.jdbc.JdbcSqlDriver");
11 Connection con
= DriverManager
.getConnection("jdbc:csql://localhost:5678", "root", "manager");
12 con
.setAutoCommit(true);
13 Statement cStmt
= con
.createStatement();
14 PreparedStatement stmt
= null;
16 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
18 for (int i
=0; i
<10; i
++)
20 stmt
= con
.prepareStatement("INSERT INTO T1 VALUES(?,?);");
22 stmt
.setString(2,"test"+i
);
23 ret
= stmt
.executeUpdate();
27 System
.out
.println("test failed");
34 cStmt
= con
.createStatement();
35 ResultSet rs
= cStmt
.executeQuery("SELECT * from T1;");
41 cStmt
.execute("DROP TABLE T1;");
49 System
.out
.println("Exception in Test: "+e
);