io.vertx.pgclient

## Interface PgConnection

- All Superinterfaces:
    SqlClient, SqlConnection

      public interface PgConnection
      extends SqlConnection

  A connection to Postgres.

  The connection object supports all the operations defined in the `SqlConnection` interface, it also provides additional support:

  - Notification
  - Request Cancellation
  Author:
    Julien Viet, Emad Alblueshi

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `PgConnection` | `cancelRequest(Handler<AsyncResult<Void>> handler)` Send a request cancellation message to tell the server to cancel processing request in this connection.
    `PgConnection` | `closeHandler(Handler<Void> handler)` Set an handler called when the connection is closed.
    `static Future<PgConnection>` | `connect(Vertx vertx)` Like `connect(Vertx, Handler)` but returns a `Future` of the asynchronous result
    `static void` | `connect(Vertx vertx, Handler<AsyncResult<PgConnection>> handler)` Like `connect(Vertx, PgConnectOptions, Handler)` with options build from the environment variables.
    `static Future<PgConnection>` | `connect(Vertx vertx, PgConnectOptions options)` Like `connect(Vertx, PgConnectOptions, Handler)` but returns a `Future` of the asynchronous result
    `static void` | `connect(Vertx vertx, PgConnectOptions options, Handler<AsyncResult<PgConnection>> handler)` Connects to the database and returns the connection if that succeeds.
    `static Future<PgConnection>` | `connect(Vertx vertx, String connectionUri)` Like `connect(Vertx, String, Handler)` but returns a `Future` of the asynchronous result
    `static void` | `connect(Vertx vertx, String connectionUri, Handler<AsyncResult<PgConnection>> handler)` Like `connect(Vertx, PgConnectOptions, Handler)` with options build from `connectionUri`.
    `PgConnection` | `exceptionHandler(Handler<Throwable> handler)` Set an handler called with connection errors.
    `PgConnection` | `notificationHandler(Handler<PgNotification> handler)` Set an handler called when the connection receives notification on a channel.
    `PgConnection` | `prepare(String sql, Handler<AsyncResult<PreparedStatement>> handler)` Create a prepared statement using the given `sql` string.
    `int` | `processId()`
    `int` | `secretKey()`

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

      `begin, begin, close, databaseMetadata, isSSL, prepare`

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

      `close, preparedQuery, query`

- - ### Method Detail

    - #### connect

          static void connect(Vertx vertx,
                              PgConnectOptions options,
                              Handler<AsyncResult<PgConnection>> handler)

      Connects to the database and returns the connection if that succeeds.

      The connection interracts directly with the database is not a proxy, so closing the connection will close the underlying connection to the database.
      Parameters:
        `vertx` - the vertx instance
        `options` - the connect options
        `handler` - the handler called with the connection or the failure

    - #### connect

          static Future<PgConnection> connect(Vertx vertx,
                                              PgConnectOptions options)

      Like `connect(Vertx, PgConnectOptions, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          static void connect(Vertx vertx,
                              Handler<AsyncResult<PgConnection>> handler)

      Like `connect(Vertx, PgConnectOptions, Handler)` with options build from the environment variables.

    - #### connect

          static Future<PgConnection> connect(Vertx vertx)

      Like `connect(Vertx, Handler)` but returns a `Future` of the asynchronous result

    - #### connect

          static void connect(Vertx vertx,
                              String connectionUri,
                              Handler<AsyncResult<PgConnection>> handler)

      Like `connect(Vertx, PgConnectOptions, Handler)` with options build from `connectionUri`.

    - #### connect

          static Future<PgConnection> connect(Vertx vertx,
                                              String connectionUri)

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

    - #### notificationHandler

          PgConnection notificationHandler(Handler<PgNotification> handler)

      Set an handler called when the connection receives notification on a channel.

      The handler is called with the `PgNotification` and has access to the channel name and the notification payload.
      Parameters:
        `handler` - the handler
      Returns:
        the transaction instance

    - #### cancelRequest

          PgConnection cancelRequest(Handler<AsyncResult<Void>> handler)

      Send a request cancellation message to tell the server to cancel processing request in this connection.
      Note: Use this with caution because the cancellation signal may or may not have any effect.
      Parameters:
        `handler` - the handler notified if cancelling request is sent
      Returns:
        a reference to this, so the API can be used fluently

    - #### processId

          int processId()

      Returns:
        The process ID of the target backend

    - #### secretKey

          int secretKey()

      Returns:
        The secret key for the target backend

    - #### prepare

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

      Create a prepared statement using the given `sql` string.
      Specified by:
        `prepare` in interface `SqlConnection`
      Parameters:
        `sql` - the sql
        `handler` - the handler notified with the prepared query asynchronously

    - #### exceptionHandler

          PgConnection exceptionHandler(Handler<Throwable> handler)

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

    - #### closeHandler

          PgConnection closeHandler(Handler<Void> handler)

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

Copyright © 2020 Eclipse. All rights reserved.