1 //Create connection, setAutocommit(false) , create Statement, insert 10 tuples, close the connection.
2 //Open another connection and check the number of tuples. It should be Zero.
5 public class ConnTest22
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(false);
14 Statement cStmt
= con
.createStatement();
17 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
18 PreparedStatement stmt
= null;
19 stmt
= con
.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
20 for (int i
=0; i
<10 ; i
++)
23 stmt
.setString(2, String
.valueOf(i
));
24 ret
= stmt
.executeUpdate();
29 con
= DriverManager
.getConnection("jdbc:csql","root","manager");
31 cStmt
= con
.createStatement();
32 ResultSet rs
= cStmt
.executeQuery("SELECT * from T1;");
38 cStmt
.execute("DROP TABLE T1;");
40 if (count
== 0) System
.exit(0); else System
.exit(1);
42 System
.out
.println("Exception in Test: "+e
);