List of usage examples for io.vertx.sqlclient Pool begin
void begin(Handler<AsyncResult<Transaction>> 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 -> { 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()); }/* w ww. j av a 2 s. c om*/ }); } }); } else { // No need to close connection as transaction will abort and be returned to the pool } }); } }); }