io.vertx.sqlclient

## Interface SqlConnection

- All Superinterfaces:
    SqlClient
  All Known Subinterfaces:
    DB2Connection, MSSQLConnection, MySQLConnection, PgConnection

      public interface SqlConnection
      extends SqlClient

  A connection to the database server.
  Author:
    Julien Viet, Emad Alblueshi

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Future<Transaction>` | `begin()` Like `begin(Handler)` but returns a `Future` of the asynchronous result
    `void` | `begin(Handler<AsyncResult<Transaction>> handler)` Begin a transaction and returns a `Transaction` for controlling and tracking this transaction.
    `void` | `close(Handler<AsyncResult<Void>> handler)` Close the current connection after all the pending commands have been processed.
    `SqlConnection` | `closeHandler(Handler<Void> handler)` Set an handler called when the connection is closed.
    `DatabaseMetadata` | `databaseMetadata()`
    `SqlConnection` | `exceptionHandler(Handler<Throwable> handler)` Set an handler called with connection errors.
    `boolean` | `isSSL()`
    `Future<PreparedStatement>` | `prepare(String sql)` Like `prepare(String, Handler)` but returns a `Future` of the asynchronous result
    `SqlConnection` | `prepare(String sql, Handler<AsyncResult<PreparedStatement>> handler)` Create a prepared statement using the given `sql` string.
    `Future<PreparedStatement>` | `prepare(String sql, PrepareOptions options)` Like `prepare(String, Handler)` but returns a `Future` of the asynchronous result
    `SqlConnection` | `prepare(String sql, PrepareOptions options, Handler<AsyncResult<PreparedStatement>> handler)` Create a prepared statement using the given `sql` string.
    `Transaction` | `transaction()`

    - ### Methods inherited from interface io.vertx.sqlclient.SqlClient

      `close, preparedQuery, preparedQuery, query`

- - ### Method Detail

    - #### prepare

          SqlConnection prepare(String sql,
                                Handler<AsyncResult<PreparedStatement>> handler)

      Create a prepared statement using the given `sql` string.
      Parameters:
        `sql` - the sql
        `handler` - the handler notified with the prepared query asynchronously

    - #### prepare

          Future<PreparedStatement> prepare(String sql)

      Like `prepare(String, Handler)` but returns a `Future` of the asynchronous result

    - #### prepare

          SqlConnection prepare(String sql,
                                PrepareOptions options,
                                Handler<AsyncResult<PreparedStatement>> handler)

      Create a prepared statement using the given `sql` string.
      Parameters:
        `sql` - the sql
        `handler` - the handler notified with the prepared query asynchronously

    - #### prepare

          Future<PreparedStatement> prepare(String sql,
                                            PrepareOptions options)

      Like `prepare(String, Handler)` but returns a `Future` of the asynchronous result

    - #### exceptionHandler

          SqlConnection exceptionHandler(Handler<Throwable> handler)

      Set an handler called with connection errors.
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### closeHandler

          SqlConnection closeHandler(Handler<Void> handler)

      Set an handler called when the connection is closed.
      Parameters:
        `handler` - the handler
      Returns:
        a reference to this, so the API can be used fluently

    - #### begin

          void begin(Handler<AsyncResult<Transaction>> handler)

      Begin a transaction and returns a `Transaction` for controlling and tracking this transaction.

      When the connection is explicitely closed, any inflight transaction is rollbacked.

    - #### begin

          Future<Transaction> begin()

      Like `begin(Handler)` but returns a `Future` of the asynchronous result

    - #### transaction

          Transaction transaction()

      Returns:
        the current transaction if it exists, otherwise null

    - #### isSSL

          boolean isSSL()

      Returns:
        whether the connection uses SSL

    - #### close

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

      Close the current connection after all the pending commands have been processed.
      Specified by:
        `close` in interface `SqlClient`
      Parameters:
        `handler` - the completion handler

    - #### databaseMetadata

          DatabaseMetadata databaseMetadata()

      Returns:
        The static metadata about the backend database server for this connection

Copyright © 2023 Eclipse. All rights reserved.