io.vertx.ext.sql

## Interface SQLClient

- All Superinterfaces:
    SQLOperations
  All Known Subinterfaces:
    JDBCClient

      public interface SQLClient
      extends SQLOperations

  A common asynchronous client interface for interacting with SQL compliant database
  Author:
    Emad Alblueshi

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default SQLClient` | `call(String sql, Handler<AsyncResult<ResultSet>> handler)` Calls the given SQL `PROCEDURE` which returns the result from the procedure.
    `default SQLClient` | `callWithParams(String sql, JsonArray params, JsonArray outputs, Handler<AsyncResult<ResultSet>> handler)` Calls the given SQL `PROCEDURE` which returns the result from the procedure.
    `void` | `close()` Close the client
    `void` | `close(Handler<AsyncResult<Void>> handler)` Close the client and release all resources.
    `SQLClient` | `getConnection(Handler<AsyncResult<SQLConnection>> handler)` Returns a connection that can be used to perform SQL operations on.
    `default SQLClient` | `query(String sql, Handler<AsyncResult<ResultSet>> handler)` Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL statement and returns it back after the execution.
    `default SQLClient` | `queryStream(String sql, Handler<AsyncResult<SQLRowStream>> handler)` Executes the given SQL `SELECT` statement which returns the results of the query as a read stream.
    `default SQLClient` | `queryStreamWithParams(String sql, JsonArray params, Handler<AsyncResult<SQLRowStream>> handler)` Executes the given SQL `SELECT` statement which returns the results of the query as a read stream.
    `default SQLClient` | `queryWithParams(String sql, JsonArray arguments, Handler<AsyncResult<ResultSet>> handler)` Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL prepared statement and returns it back after the execution.
    `default SQLClient` | `update(String sql, Handler<AsyncResult<UpdateResult>> handler)` Executes the given SQL statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement.
    `default SQLClient` | `updateWithParams(String sql, JsonArray params, Handler<AsyncResult<UpdateResult>> handler)` Executes the given prepared statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement with the given parameters

    - ### Methods inherited from interface io.vertx.ext.sql.SQLOperations

      `querySingle, querySingleWithParams`

- - ### Method Detail

    - #### getConnection

          SQLClient getConnection(Handler<AsyncResult<SQLConnection>> handler)

      Returns a connection that can be used to perform SQL operations on. It's important to remember to close the connection when you are done, so it is returned to the pool.
      Parameters:
        `handler` - the handler which is called when the `JdbcConnection` object is ready for use.

    - #### close

          void close(Handler<AsyncResult<Void>> handler)

      Close the client and release all resources. Call the handler when close is complete.
      Parameters:
        `handler` - the handler that will be called when close is complete

    - #### close

          void close()

      Close the client

    - #### query

          default SQLClient query(String sql,
                                  Handler<AsyncResult<ResultSet>> handler)

      Execute a single SQL statement, this method acquires a connection from the the pool and executes the SQL statement and returns it back after the execution.
      Specified by:
        `query` in interface `SQLOperations`
      Parameters:
        `sql` - the statement to execute
        `handler` - the result handler
      Returns:
        self
      See Also:
        `Statement.executeQuery(String)`, `Statement.executeQuery(String)`

    - #### queryStream

          default SQLClient queryStream(String sql,
                                        Handler<AsyncResult<SQLRowStream>> handler)

      Executes the given SQL `SELECT` statement which returns the results of the query as a read stream.
      Specified by:
        `queryStream` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `SELECT * FROM table ...`.
        `handler` - the handler which is called once the operation completes. It will return a `SQLRowStream`.
      See Also:
        `Statement.executeQuery(String)`, `Statement.executeQuery(String)`

    - #### queryStreamWithParams

          default SQLClient queryStreamWithParams(String sql,
                                                  JsonArray params,
                                                  Handler<AsyncResult<SQLRowStream>> handler)

      Executes the given SQL `SELECT` statement which returns the results of the query as a read stream.
      Specified by:
        `queryStreamWithParams` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `SELECT * FROM table ...`.
        `params` - these are the parameters to fill the statement.
        `handler` - the handler which is called once the operation completes. It will return a `SQLRowStream`.
      See Also:
        `Statement.executeQuery(String)`, `Statement.executeQuery(String)`

    - #### queryWithParams

          default SQLClient queryWithParams(String sql,
                                            JsonArray arguments,
                                            Handler<AsyncResult<ResultSet>> handler)

      Execute a single SQL prepared statement, this method acquires a connection from the the pool and executes the SQL prepared statement and returns it back after the execution.
      Specified by:
        `queryWithParams` in interface `SQLOperations`
      Parameters:
        `sql` - the statement to execute
        `arguments` - the arguments to the statement
        `handler` - the result handler
      Returns:
        self
      See Also:
        `Statement.executeQuery(String)`, `Statement.executeQuery(String)`

    - #### update

          default SQLClient update(String sql,
                                   Handler<AsyncResult<UpdateResult>> handler)

      Executes the given SQL statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement.
      Specified by:
        `update` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `INSERT INTO table ...`
        `handler` - the handler which is called once the operation completes.
      See Also:
        `Statement.executeUpdate(String)`, `Statement.executeUpdate(String)`

    - #### updateWithParams

          default SQLClient updateWithParams(String sql,
                                             JsonArray params,
                                             Handler<AsyncResult<UpdateResult>> handler)

      Executes the given prepared statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement with the given parameters
      Specified by:
        `updateWithParams` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `INSERT INTO table ...`
        `params` - these are the parameters to fill the statement.
        `handler` - the handler which is called once the operation completes.
      See Also:
        `Statement.executeUpdate(String)`, `Statement.executeUpdate(String)`

    - #### call

          default SQLClient call(String sql,
                                 Handler<AsyncResult<ResultSet>> handler)

      Calls the given SQL `PROCEDURE` which returns the result from the procedure.
      Specified by:
        `call` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `{call getEmpName}`.
        `handler` - the handler which is called once the operation completes. It will return a `ResultSet`.
      See Also:
        `Statement.execute(String)`

    - #### callWithParams

          default SQLClient callWithParams(String sql,
                                           JsonArray params,
                                           JsonArray outputs,
                                           Handler<AsyncResult<ResultSet>> handler)

      Calls the given SQL `PROCEDURE` which returns the result from the procedure. The index of params and outputs are important for both arrays, for example when dealing with a prodecure that takes the first 2 arguments as input values and the 3 arg as an output then the arrays should be like:

             params = [VALUE1, VALUE2, null]
             outputs = [null, null, "VARCHAR"]

      Specified by:
        `callWithParams` in interface `SQLOperations`
      Parameters:
        `sql` - the SQL to execute. For example `{call getEmpName (?, ?)}`.
        `params` - these are the parameters to fill the statement.
        `outputs` - these are the outputs to fill the statement.
        `handler` - the handler which is called once the operation completes. It will return a `ResultSet`.
      See Also:
        `Statement.execute(String)`

Copyright © 2022 Eclipse. All rights reserved.