Hi Julian,
In SQLite JDBC, auto commit mode is on by default, that means there is
no need to
wrap a single update operation with begin and commit statements.
Each update operation is automatically wrapped with begin and commit.
If you have to pack multiple update operations within a transaction,
first you have to set the auto commit mode to false by calling
Connection.setAutoCommit(false) method.
Then, issue commit. In this case, the update data not stored on the
disk before the commit.
ResultSet rs;
String countSql = "select count(*) from trans;";
stat1.executeUpdate("create table trans (c1);");
conn1.setAutoCommit(false);
assertEquals(1, stat1.executeUpdate("insert into trans values
(4);"));
// transaction not yet commited, conn1 can see, conn2 can not
rs = stat1.executeQuery(countSql);
assertTrue(rs.next());
assertEquals(1, rs.getInt(1));
rs.close();
rs = stat2.executeQuery(countSql);
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
conn1.commit();