Package: io.vertx.groovy.ext.sql

## [Groovy] Class SQLConnection

- io.vertx.groovy.ext.sql.SQLConnection

- Represents a connection to a SQL database

- - ### Constructor Summary

    Constructors
    Constructor and description
    `SQLConnection (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `SQLConnection` | `batch(java.util.List<java.lang.String> sqlStatements, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)` Batch simple SQL strings and execute the batch where the async result contains a array of Integers.
    `SQLConnection` | `batchCallableWithParams(java.lang.String sqlStatement, java.util.List<java.util.List<java.lang.Object>> inArgs, java.util.List<java.util.List<java.lang.Object>> outArgs, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)` Batch a callable statement with all entries from the args list.
    `SQLConnection` | `batchWithParams(java.lang.String sqlStatement, java.util.List<java.util.List<java.lang.Object>> args, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)` Batch a prepared statement with all entries from the args list.
    `SQLConnection` | `call(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Calls the given SQL `PROCEDURE` which returns the result from the procedure.
    `SQLConnection` | `callWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, java.util.List<java.lang.Object> outputs, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Calls the given SQL `PROCEDURE` which returns the result from the procedure.
    `void` | `close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)` Closes the connection.
    `void` | `close()` Closes the connection.
    `SQLConnection` | `commit(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)` Commits all changes made since the previous commit/rollback.
    `SQLConnection` | `execute(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)` Executes the given SQL statement
    `java.lang.Object` | `getDelegate()`
    `SQLConnection` | `getTransactionIsolation(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.sql.TransactionIsolation>> handler)` Attempts to return the transaction isolation level for this Connection object to the one given.
    `SQLConnection` | `query(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Executes the given SQL `SELECT` statement which returns the results of the query.
    `SQLConnection` | `queryWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Executes the given SQL `SELECT` prepared statement which returns the results of the query.
    `SQLConnection` | `rollback(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)` Rolls back all changes made since the previous commit/rollback.
    `SQLConnection` | `setAutoCommit(boolean autoCommit, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)` Sets the auto commit flag for this connection.
    `SQLConnection` | `setQueryTimeout(int timeoutInSeconds)` Sets a connection wide query timeout.
    `SQLConnection` | `setTransactionIsolation(io.vertx.ext.sql.TransactionIsolation isolation, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)` Attempts to change the transaction isolation level for this Connection object to the one given.
    `SQLConnection` | `update(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Executes the given SQL statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement.
    `SQLConnection` | `updateWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)` Executes the given prepared statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement with the given parameters

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### SQLConnection(java.lang.Object delegate)

  - ### Method Detail

    - #### SQLConnection batch(java.util.List<java.lang.String> sqlStatements, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)

      Batch simple SQL strings and execute the batch where the async result contains a array of Integers.

      Returns:
      Parameters:
        `sqlStatements` - sql statement
        `handler` - the result handler

    - #### SQLConnection batchCallableWithParams(java.lang.String sqlStatement, java.util.List<java.util.List<java.lang.Object>> inArgs, java.util.List<java.util.List<java.lang.Object>> outArgs, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)

      Batch a callable statement with all entries from the args list. Each entry is a batch. The size of the lists inArgs and outArgs MUST be the equal. The operation completes with the execution of the batch where the async result contains a array of Integers.

      Returns:
      Parameters:
        `sqlStatement` - sql statement
        `inArgs` - the callable statement input arguments
        `outArgs` - the callable statement output arguments
        `handler` - the result handler

    - #### SQLConnection batchWithParams(java.lang.String sqlStatement, java.util.List<java.util.List<java.lang.Object>> args, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.Integer>>> handler)

      Batch a prepared statement with all entries from the args list. Each entry is a batch. The operation completes with the execution of the batch where the async result contains a array of Integers.

      Returns:
      Parameters:
        `sqlStatement` - sql statement
        `args` - the prepared statement arguments
        `handler` - the result handler

    - #### SQLConnection call(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      Calls the given SQL `PROCEDURE` which returns the result from the procedure.

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `{call getEmpName (?, ?)}`.
        `resultHandler` - the handler which is called once the operation completes. It will return a `ResultSet`.

    - #### SQLConnection callWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, java.util.List<java.lang.Object> outputs, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      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"]

      Returns:
      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.
        `resultHandler` - the handler which is called once the operation completes. It will return a `ResultSet`.

    - #### void close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)

      Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

      Parameters:
        `handler` - the handler called when this operation completes.

    - #### void close()

      Closes the connection. Important to always close the connection when you are done so it's returned to the pool.

    - #### SQLConnection commit(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)

      Commits all changes made since the previous commit/rollback.

      Returns:
      Parameters:
        `handler` - the handler called when this operation completes.

    - #### SQLConnection execute(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)

      Executes the given SQL statement

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `CREATE TABLE IF EXISTS table ...`
        `resultHandler` - the handler which is called once this operation completes.

    - #### java.lang.Object getDelegate()

    - #### SQLConnection getTransactionIsolation(io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.ext.sql.TransactionIsolation>> handler)

      Attempts to return the transaction isolation level for this Connection object to the one given.

      Returns:
      Parameters:
        `handler` - the handler called when this operation completes.

    - #### SQLConnection query(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      Executes the given SQL `SELECT` statement which returns the results of the query.

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `SELECT * FROM table ...`.
        `resultHandler` - the handler which is called once the operation completes. It will return a `ResultSet`.

    - #### SQLConnection queryWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      Executes the given SQL `SELECT` prepared statement which returns the results of the query.

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `SELECT * FROM table ...`.
        `params` - these are the parameters to fill the statement.
        `resultHandler` - the handler which is called once the operation completes. It will return a `ResultSet`.

    - #### SQLConnection rollback(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)

      Rolls back all changes made since the previous commit/rollback.

      Returns:
      Parameters:
        `handler` - the handler called when this operation completes.

    - #### SQLConnection setAutoCommit(boolean autoCommit, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> resultHandler)

      Sets the auto commit flag for this connection. True by default.

      Returns:
      Parameters:
        `autoCommit` - the autoCommit flag, true by default.
        `resultHandler` - the handler which is called once this operation completes.

    - #### SQLConnection setQueryTimeout(int timeoutInSeconds)

      Sets a connection wide query timeout. It can be over written at any time and becomes active on the next query call.

      Returns:
      Parameters:
        `timeoutInSeconds` - the max amount of seconds the query can take to execute.

    - #### SQLConnection setTransactionIsolation(io.vertx.ext.sql.TransactionIsolation isolation, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler)

      Attempts to change the transaction isolation level for this Connection object to the one given. The constants defined in the interface Connection are the possible transaction isolation levels.

      Returns:
      Parameters:
        `isolation` - the level of isolation
        `handler` - the handler called when this operation completes.

    - #### SQLConnection update(java.lang.String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      Executes the given SQL statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement.

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `INSERT INTO table ...`
        `resultHandler` - the handler which is called once the operation completes.

    - #### SQLConnection updateWithParams(java.lang.String sql, java.util.List<java.lang.Object> params, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.Map<java.lang.String, java.lang.Object>>> resultHandler)

      Executes the given prepared statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement with the given parameters

      Returns:
      Parameters:
        `sql` - the SQL to execute. For example `INSERT INTO table ...`
        `params` - these are the parameters to fill the statement.
        `resultHandler` - the handler which is called once the operation completes.