Class SQLClient

  • All Implemented Interfaces:
    SQLOperations
    Direct Known Subclasses:
    JDBCClient

    public class SQLClient
    extends Object
    implements SQLOperations
    A common asynchronous client interface for interacting with SQL compliant database

    NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

    • Constructor Detail

      • SQLClient

        public SQLClient​(io.vertx.ext.sql.SQLClient delegate)
      • SQLClient

        public SQLClient​(Object delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • querySingle

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.core.json.JsonArray> querySingle​(String sql)
        Execute a one shot SQL statement that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        querySingle in interface SQLOperations
        Parameters:
        sql - the statement to execute
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • querySingleAndAwait

        public io.vertx.core.json.JsonArray querySingleAndAwait​(String sql)
        Blocking variant of SQLOperations.querySingle(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        querySingleAndAwait in interface SQLOperations
        Parameters:
        sql - the statement to execute
        Returns:
        the JsonArray instance produced by the operation.
      • querySingleWithParams

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.core.json.JsonArray> querySingleWithParams​(String sql,
                                                                                          io.vertx.core.json.JsonArray arguments)
        Execute a one shot SQL statement with arguments that returns a single SQL row. This method will reduce the boilerplate code by getting a connection from the pool (this object) and return it back after the execution. Only the first result from the result set is returned.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        querySingleWithParams in interface SQLOperations
        Parameters:
        sql - the statement to execute
        arguments - the arguments
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • querySingleWithParamsAndAwait

        public io.vertx.core.json.JsonArray querySingleWithParamsAndAwait​(String sql,
                                                                          io.vertx.core.json.JsonArray arguments)
        Blocking variant of SQLOperations.querySingleWithParams(String,JsonArray).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        querySingleWithParamsAndAwait in interface SQLOperations
        Parameters:
        sql - the statement to execute
        arguments - the arguments
        Returns:
        the JsonArray instance produced by the operation.
      • getConnection

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<SQLConnection> getConnection()
        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.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • getConnectionAndAwait

        public SQLConnection getConnectionAndAwait()
        Blocking variant of getConnection().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the SQLConnection instance produced by the operation.
      • getConnectionAndForget

        public SQLClient getConnectionAndForget()
        Variant of getConnection() that ignores the result of the operation.

        This method subscribes on the result of getConnection(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from getConnection() but you don't need to compose it with other operations.

        Returns:
        the instance of SQLClient to chain method calls.
      • close

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<Void> close()
        Close the client and release all resources. Call the handler when close is complete.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • closeAndAwait

        public Void closeAndAwait()
        Blocking variant of close().

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Returns:
        the Void instance produced by the operation.
      • closeAndForget

        public void closeAndForget()
        Variant of close() that ignores the result of the operation.

        This method subscribes on the result of close(), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from close() but you don't need to compose it with other operations.

      • query

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.ResultSet> query​(String sql)
        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.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        query in interface SQLOperations
        Parameters:
        sql - the statement to execute
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • queryAndAwait

        public io.vertx.ext.sql.ResultSet queryAndAwait​(String sql)
        Blocking variant of query(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        queryAndAwait in interface SQLOperations
        Parameters:
        sql - the statement to execute
        Returns:
        the ResultSet instance produced by the operation.
      • queryAndForget

        public SQLClient queryAndForget​(String sql)
        Variant of query(String) that ignores the result of the operation.

        This method subscribes on the result of query(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from query(String) but you don't need to compose it with other operations.

        Specified by:
        queryAndForget in interface SQLOperations
        Parameters:
        sql - the statement to execute
        Returns:
        the instance of SQLClient to chain method calls.
      • queryStream

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<SQLRowStream> queryStream​(String sql)
        Executes the given SQL SELECT statement which returns the results of the query as a read stream.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        queryStream in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example SELECT * FROM table ....
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • queryStreamAndAwait

        public SQLRowStream queryStreamAndAwait​(String sql)
        Blocking variant of queryStream(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        queryStreamAndAwait in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example SELECT * FROM table ....
        Returns:
        the SQLRowStream instance produced by the operation.
      • queryStreamAndForget

        public SQLClient queryStreamAndForget​(String sql)
        Variant of queryStream(String) that ignores the result of the operation.

        This method subscribes on the result of queryStream(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from queryStream(String) but you don't need to compose it with other operations.

        Specified by:
        queryStreamAndForget in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example SELECT * FROM table ....
        Returns:
        the instance of SQLClient to chain method calls.
      • queryStreamWithParams

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<SQLRowStream> queryStreamWithParams​(String sql,
                                                                          io.vertx.core.json.JsonArray params)
        Executes the given SQL SELECT statement which returns the results of the query as a read stream.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        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.
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • queryStreamWithParamsAndAwait

        public SQLRowStream queryStreamWithParamsAndAwait​(String sql,
                                                          io.vertx.core.json.JsonArray params)
        Blocking variant of queryStreamWithParams(String,JsonArray).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        queryStreamWithParamsAndAwait in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example SELECT * FROM table ....
        params - these are the parameters to fill the statement.
        Returns:
        the SQLRowStream instance produced by the operation.
      • queryWithParams

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.ResultSet> queryWithParams​(String sql,
                                                                                  io.vertx.core.json.JsonArray arguments)
        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.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        queryWithParams in interface SQLOperations
        Parameters:
        sql - the statement to execute
        arguments - the arguments to the statement
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • queryWithParamsAndAwait

        public io.vertx.ext.sql.ResultSet queryWithParamsAndAwait​(String sql,
                                                                  io.vertx.core.json.JsonArray arguments)
        Blocking variant of queryWithParams(String,JsonArray).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        queryWithParamsAndAwait in interface SQLOperations
        Parameters:
        sql - the statement to execute
        arguments - the arguments to the statement
        Returns:
        the ResultSet instance produced by the operation.
      • update

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.UpdateResult> update​(String sql)
        Executes the given SQL statement which may be an INSERT, UPDATE, or DELETE statement.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        update in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example INSERT INTO table ...
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • updateAndAwait

        public io.vertx.ext.sql.UpdateResult updateAndAwait​(String sql)
        Blocking variant of update(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        updateAndAwait in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example INSERT INTO table ...
        Returns:
        the UpdateResult instance produced by the operation.
      • updateAndForget

        public SQLClient updateAndForget​(String sql)
        Variant of update(String) that ignores the result of the operation.

        This method subscribes on the result of update(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from update(String) but you don't need to compose it with other operations.

        Specified by:
        updateAndForget in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example INSERT INTO table ...
        Returns:
        the instance of SQLClient to chain method calls.
      • updateWithParams

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.UpdateResult> updateWithParams​(String sql,
                                                                                      io.vertx.core.json.JsonArray params)
        Executes the given prepared statement which may be an INSERT, UPDATE, or DELETE statement with the given parameters

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        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.
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • updateWithParamsAndAwait

        public io.vertx.ext.sql.UpdateResult updateWithParamsAndAwait​(String sql,
                                                                      io.vertx.core.json.JsonArray params)
        Blocking variant of updateWithParams(String,JsonArray).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        updateWithParamsAndAwait in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example INSERT INTO table ...
        params - these are the parameters to fill the statement.
        Returns:
        the UpdateResult instance produced by the operation.
      • call

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.ResultSet> call​(String sql)
        Calls the given SQL PROCEDURE which returns the result from the procedure.

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Specified by:
        call in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example {call getEmpName}.
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • callAndAwait

        public io.vertx.ext.sql.ResultSet callAndAwait​(String sql)
        Blocking variant of call(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        callAndAwait in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example {call getEmpName}.
        Returns:
        the ResultSet instance produced by the operation.
      • callAndForget

        public SQLClient callAndForget​(String sql)
        Variant of call(String) that ignores the result of the operation.

        This method subscribes on the result of call(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from call(String) but you don't need to compose it with other operations.

        Specified by:
        callAndForget in interface SQLOperations
        Parameters:
        sql - the SQL to execute. For example {call getEmpName}.
        Returns:
        the instance of SQLClient to chain method calls.
      • callWithParams

        @CheckReturnValue
        public io.smallrye.mutiny.Uni<io.vertx.ext.sql.ResultSet> callWithParams​(String sql,
                                                                                 io.vertx.core.json.JsonArray params,
                                                                                 io.vertx.core.json.JsonArray outputs)
        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"]
         

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        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.
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • callWithParamsAndAwait

        public io.vertx.ext.sql.ResultSet callWithParamsAndAwait​(String sql,
                                                                 io.vertx.core.json.JsonArray params,
                                                                 io.vertx.core.json.JsonArray outputs)
        Blocking variant of callWithParams(String,JsonArray,JsonArray).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Specified by:
        callWithParamsAndAwait 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.
        Returns:
        the ResultSet instance produced by the operation.
      • newInstance

        public static SQLClient newInstance​(io.vertx.ext.sql.SQLClient arg)