List of usage examples for io.vertx.pgclient PgPool query
PgPool query(String sql, Handler<AsyncResult<RowSet<Row>>> handler);
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 {/* w w w .j av a 2s . co m*/ System.out.println("Failure: " + ar.cause().getMessage()); } // Now close the pool client.close(); }); }