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.
4 public class ConnTest22
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(false);
13 Statement cStmt
= con
.createStatement();
16 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
17 PreparedStatement stmt
= null;
18 stmt
= con
.prepareStatement("INSERT INTO T1 VALUES (?, ?);");
19 for (int i
=0; i
<10 ; i
++)
22 stmt
.setString(2, String
.valueOf(i
));
23 ret
= stmt
.executeUpdate();
28 con
= DriverManager
.getConnection("jdbc:csql","root","manager");
30 cStmt
= con
.createStatement();
31 ResultSet rs
= cStmt
.executeQuery("SELECT * from T1;");
37 cStmt
.execute("DROP TABLE T1;");
39 if (count
== 0) System
.exit(0); else System
.exit(1);
41 System
.out
.println("Exception in Test: "+e
);