List of usage examples for io.vertx.sqlclient PreparedQuery cursor
Cursor cursor(Tuple args);
From source file:examples.SqlClientExamples.java
License:Apache License
public void usingCursors01(SqlConnection connection) { connection.prepare("SELECT * FROM users WHERE first_name LIKE $1", ar1 -> { if (ar1.succeeded()) { PreparedQuery pq = ar1.result(); // Cursors require to run within a transaction Transaction tx = connection.begin(); // Create a cursor Cursor cursor = pq.cursor(Tuple.of("julien")); // Read 50 rows cursor.read(50, ar2 -> {// w w w . j a v a 2 s . co m if (ar2.succeeded()) { RowSet<Row> rows = ar2.result(); // Check for more ? if (cursor.hasMore()) { // Repeat the process... } else { // No more rows - commit the transaction tx.commit(); } } }); } }); }
From source file:examples.SqlClientExamples.java
License:Apache License
public void usingCursors01(SqlConnection connection) { connection.prepare("SELECT * FROM users WHERE age > ?", ar1 -> { if (ar1.succeeded()) { PreparedQuery pq = ar1.result(); // Create a cursor Cursor cursor = pq.cursor(Tuple.of(18)); // Read 50 rows cursor.read(50, ar2 -> {//from w w w . ja v a2 s. co m if (ar2.succeeded()) { RowSet<Row> rows = ar2.result(); // Check for more ? if (cursor.hasMore()) { // Repeat the process... } else { // No more rows - close the cursor cursor.close(); } } }); } }); }