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 (Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `close(Handler<AsyncResult<Void>> handler)` Closes the connection.
    `void` | `close()` Closes the connection.
    `SQLConnection` | `commit(Handler<AsyncResult<Void>> handler)` Commits all changes made since the previous commit/rollback.
    `SQLConnection` | `execute(String sql, Handler<AsyncResult<Void>> resultHandler)` Executes the given SQL statement
    `Object` | `getDelegate()`
    `SQLConnection` | `query(String sql, Handler<AsyncResult<Map<String, Object>>> resultHandler)` Executes the given SQL `SELECT` statement which returns the results of the query.
    `SQLConnection` | `queryWithParams(String sql, List<Object> params, Handler<AsyncResult<Map<String, Object>>> resultHandler)` Executes the given SQL `SELECT` prepared statement which returns the results of the query.
    `SQLConnection` | `rollback(Handler<AsyncResult<Void>> handler)` Rolls back all changes made since the previous commit/rollback.
    `SQLConnection` | `setAutoCommit(boolean autoCommit, Handler<AsyncResult<Void>> resultHandler)` Sets the auto commit flag for this connection.
    `SQLConnection` | `update(String sql, Handler<AsyncResult<Map<String, Object>>> resultHandler)` Executes the given SQL statement which may be an `INSERT`, `UPDATE`, or `DELETE` statement.
    `SQLConnection` | `updateWithParams(String sql, List<Object> params, Handler<AsyncResult<Map<String, 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 Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### SQLConnection(Object delegate)

  - ### Method Detail

    - #### void close(Handler<AsyncResult<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(Handler<AsyncResult<Void>> handler)

      Commits all changes made since the previous commit/rollback.

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

    - #### SQLConnection execute(String sql, Handler<AsyncResult<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.

    - #### Object getDelegate()

    - #### SQLConnection query(String sql, Handler<AsyncResult<Map<String, 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(String sql, List<Object> params, Handler<AsyncResult<Map<String, 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(Handler<AsyncResult<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, Handler<AsyncResult<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 update(String sql, Handler<AsyncResult<Map<String, 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(String sql, List<Object> params, Handler<AsyncResult<Map<String, 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.