List of usage examples for io.vertx.sqlclient Transaction query
@Override Transaction query(String sql, Handler<AsyncResult<RowSet<Row>>> handler);
From source file:examples.SqlClientExamples.java
License:Apache License
public void transaction03(Pool pool) { // Acquire a transaction and begin the transaction pool.begin(res -> {/*w ww.ja v a 2 s . c om*/ if (res.succeeded()) { // Get the transaction Transaction tx = res.result(); // Various statements tx.query("INSERT INTO Users (first_name,last_name) VALUES ('Julien','Viet')", ar1 -> { if (ar1.succeeded()) { tx.query("INSERT INTO Users (first_name,last_name) VALUES ('Emad','Alblueshi')", ar2 -> { if (ar2.succeeded()) { // Commit the transaction // the connection will automatically return to the pool tx.commit(ar3 -> { if (ar3.succeeded()) { System.out.println("Transaction succeeded"); } else { System.out.println("Transaction failed " + ar3.cause().getMessage()); } }); } }); } else { // No need to close connection as transaction will abort and be returned to the pool } }); } }); }