1 //Open two connections and call setTransactionIsolation(TRANSACTION_UNCOMMITTED ).
2 //From 1st connection insert tuple and then sleep, from 2nd connection try to select the inserted tuple.
3 //Tuple should be seen.
7 public static void main(String
[] args
)
11 Class
.forName("csql.jdbc.JdbcSqlDriver");
12 Connection con1
= DriverManager
.getConnection("jdbc:csql://localhost:5678", "root", "manager");
13 Connection con2
= DriverManager
.getConnection("jdbc:csql://localhost:5678", "root", "manager");
14 if ( (con1
== null) || (con2
== null) )
15 System
.out
.println("test failed!");
16 con1
.setTransactionIsolation(Connection
.TRANSACTION_READ_UNCOMMITTED
);
17 con2
.setTransactionIsolation(Connection
.TRANSACTION_READ_UNCOMMITTED
);
18 con1
.setAutoCommit(false);
19 con2
.setAutoCommit(false);
20 Statement cStmt
= con1
.createStatement();
21 cStmt
.execute("CREATE TABLE T1(f1 integer,f2 char(20));");
22 PreparedStatement stmt
= null;
23 stmt
= con1
.prepareStatement("INSERT INTO T1 VALUES(?,?);");
25 stmt
.setString(2,"test");
27 ret
= stmt
.executeUpdate();
34 cStmt
= con2
.createStatement();
35 ResultSet rs
= cStmt
.executeQuery("SELECT * FROM T1;");
42 cStmt
.execute("DROP TABLE T1;");
45 if (count
!=1) System
.exit(1); else System
.exit(0);
47 System
.out
.println(e
.getMessage());