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