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
5 public class ConnTest34
7 public static void main(String
[] args
)
11 Class
.forName("csql.jdbc.JdbcSqlDriver");
12 Connection con
= DriverManager
.getConnection("jdbc:csql", "root", "manager");
13 con
.setAutoCommit(true);
14 Statement cStmt
= con
.createStatement();
15 PreparedStatement stmt
= null;
17 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
19 for (int i
=0; i
<10; i
++)
21 stmt
= con
.prepareStatement("INSERT INTO T1 VALUES(?,?);");
23 stmt
.setString(2,"test"+i
);
24 ret
= stmt
.executeUpdate();
28 System
.out
.println("test failed");
35 cStmt
= con
.createStatement();
36 ResultSet rs
= cStmt
.executeQuery("SELECT * from T1;");
42 cStmt
.execute("DROP TABLE T1;");
50 System
.out
.println("Exception in Test: "+e
);