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