Example usage for io.vertx.sqlclient Cursor hasMore

List of usage examples for io.vertx.sqlclient Cursor hasMore

Introduction

In this page you can find the example usage for io.vertx.sqlclient Cursor hasMore.

Prototype

boolean hasMore();

Source Link

Document

Returns true when the cursor has results in progress and the #read should be called to retrieve them.

Usage

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 -> {//from  w  w w . j  ava2 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   ww w  .j a  va 2 s.  com
                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();
                    }
                }
            });
        }
    });
}