Today we play with something we don't normally do in a live application. We are going to married Atomikos and Sql2o.
Atomikos is a lightweight transaction manager for Java that enables applications using distributed transactions to be self-contained.
Sql2o is a small Java library, that makes it easy to execute sql statements against your JDBC compliant database.
We normally use Atomikos to manage the transaction. Sql2o also has it's own way for transaction management.
// Sql2o Transaction
String sql1 = "INSERT INTO SomeTable(id, value) VALUES (:id, :value)";
String sql2 = "UPDATE SomeOtherTable SET value = :val WHERE id = :id";
try (Connection con = sql2o.beginTransaction()) {
con.createQuery(sql1).addParameter("id", idVariable1).addParameter("val", valueVariable1).executeUpdate();
con.createQuery(sql2).addParameter("id", idVariable2).addParameter("val", valueVariable2).executeUpdate();
con.commit();
} So if we mix the two together, what kind of chemistry they will create?

