List of usage examples for io.vertx.sqlclient SqlResult value
T value();
From source file:examples.MySQLClientExamples.java
public void collector01Example(SqlClient client) { // Create a collector projecting a row set to a map Collector<Row, ?, Map<Long, String>> collector = Collectors.toMap(row -> row.getLong("id"), row -> row.getString("last_name")); // Run the query with the collector client.query("SELECT * FROM users", collector, ar -> { if (ar.succeeded()) { SqlResult<Map<Long, String>> result = ar.result(); // Get the map created by the collector Map<Long, String> map = result.value(); System.out.println("Got " + map); } else {//from w w w . ja v a 2 s.co m System.out.println("Failure: " + ar.cause().getMessage()); } }); }
From source file:examples.MySQLClientExamples.java
public void collector02Example(SqlClient client) { // Create a collector projecting a row set to a (last_name_1,last_name_2,...) Collector<Row, ?, String> collector = Collectors.mapping(row -> row.getString("last_name"), Collectors.joining(",", "(", ")")); // Run the query with the collector client.query("SELECT * FROM users", collector, ar -> { if (ar.succeeded()) { SqlResult<String> result = ar.result(); // Get the string created by the collector String list = result.value(); System.out.println("Got " + list); } else {/*from w ww . j av a 2 s .c o m*/ System.out.println("Failure: " + ar.cause().getMessage()); } }); }