List of usage examples for io.vertx.sqlclient PoolOptions PoolOptions
public PoolOptions()
From source file:examples.MySQLClientExamples.java
public void gettingStarted() { // Connect options MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the client pool MySQLPool client = MySQLPool.pool(connectOptions, poolOptions); // A simple query client.query("SELECT * FROM users WHERE id='julien'", ar -> { if (ar.succeeded()) { RowSet<Row> result = ar.result(); System.out.println("Got " + result.size() + " rows "); } else {//w w w .j ava 2s . com System.out.println("Failure: " + ar.cause().getMessage()); } // Now close the pool client.close(); }); }
From source file:examples.MySQLClientExamples.java
public void configureFromDataObject(Vertx vertx) { // Data object MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool Options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pool from the data object MySQLPool pool = MySQLPool.pool(vertx, connectOptions, poolOptions); pool.getConnection(ar -> {//ww w . j a v a 2 s. c o m // Handling your connection }); }
From source file:examples.MySQLClientExamples.java
public void connecting01() { // Connect options MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client MySQLPool client = MySQLPool.pool(connectOptions, poolOptions); }
From source file:examples.MySQLClientExamples.java
public void connecting02(Vertx vertx) { // Connect options MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client MySQLPool client = MySQLPool.pool(vertx, connectOptions, poolOptions); }
From source file:examples.MySQLClientExamples.java
public void connecting04(Vertx vertx) { // Connect options MySQLConnectOptions connectOptions = new MySQLConnectOptions().setPort(3306).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client MySQLPool client = MySQLPool.pool(vertx, connectOptions, poolOptions); // Get a connection from the pool client.getConnection(ar1 -> {//from ww w . j a va 2s. c o m if (ar1.succeeded()) { System.out.println("Connected"); // Obtain our connection SqlConnection conn = ar1.result(); // All operations execute on the same connection conn.query("SELECT * FROM users WHERE id='julien'", ar2 -> { if (ar2.succeeded()) { conn.query("SELECT * FROM users WHERE id='emad'", ar3 -> { // Release the connection to the pool conn.close(); }); } else { // Release the connection to the pool conn.close(); } }); } else { System.out.println("Could not connect: " + ar1.cause().getMessage()); } }); }
From source file:examples.PgClientExamples.java
License:Apache License
public void gettingStarted() { // Connect options PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the client pool PgPool client = PgPool.pool(connectOptions, poolOptions); // A simple query client.query("SELECT * FROM users WHERE id='julien'", ar -> { if (ar.succeeded()) { RowSet<Row> result = ar.result(); System.out.println("Got " + result.size() + " rows "); } else {/*from w w w .j a v a2 s . co m*/ System.out.println("Failure: " + ar.cause().getMessage()); } // Now close the pool client.close(); }); }
From source file:examples.PgClientExamples.java
License:Apache License
public void configureFromDataObject(Vertx vertx) { // Data object PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool Options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pool from the data object PgPool pool = PgPool.pool(vertx, connectOptions, poolOptions); pool.getConnection(ar -> {//w w w.ja v a2s. c om // Handling your connection }); }
From source file:examples.PgClientExamples.java
License:Apache License
public void connecting01() { // Connect options PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client PgPool client = PgPool.pool(connectOptions, poolOptions); }
From source file:examples.PgClientExamples.java
License:Apache License
public void connecting02(Vertx vertx) { // Connect options PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client PgPool client = PgPool.pool(vertx, connectOptions, poolOptions); }
From source file:examples.PgClientExamples.java
License:Apache License
public void connecting04(Vertx vertx) { // Connect options PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("the-host") .setDatabase("the-db").setUser("user").setPassword("secret"); // Pool options PoolOptions poolOptions = new PoolOptions().setMaxSize(5); // Create the pooled client PgPool client = PgPool.pool(vertx, connectOptions, poolOptions); // Get a connection from the pool client.getConnection(ar1 -> {//from w ww .ja v a2 s . c o m if (ar1.succeeded()) { System.out.println("Connected"); // Obtain our connection SqlConnection conn = ar1.result(); // All operations execute on the same connection conn.query("SELECT * FROM users WHERE id='julien'", ar2 -> { if (ar2.succeeded()) { conn.query("SELECT * FROM users WHERE id='emad'", ar3 -> { // Release the connection to the pool conn.close(); }); } else { // Release the connection to the pool conn.close(); } }); } else { System.out.println("Could not connect: " + ar1.cause().getMessage()); } }); }