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 Details

    • connect

      static Future<PgConnection> connect(Vertx vertx, PgConnectOptions options)
      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
      Returns:
      a future notified with the connection or the failure
    • connect

      static Future<PgConnection> connect(Vertx vertx)
      Like connect(Vertx, PgConnectOptions) with options build from the environment variables.
    • connect

      static Future<PgConnection> connect(Vertx vertx, String connectionUri)
      Like connect(Vertx, PgConnectOptions) with options build from connectionUri.
    • notificationHandler

      PgConnection notificationHandler(Handler<PgNotification> handler)
      Set a 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
    • noticeHandler

      PgConnection noticeHandler(Handler<PgNotice> handler)
      Set a handler called when the connection receives a notice from the server.
      Parameters:
      handler -
      Returns:
    • cancelRequest

      Future<Void> cancelRequest()
      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.
      Returns:
      a future notified if cancelling request is sent
    • processId

      int processId()
      Returns:
      The process ID of the target backend
    • secretKey

      int secretKey()
      Returns:
      The secret key for the target backend
    • 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
    • cast

      static PgConnection cast(SqlConnection sqlConnection)
      Cast a SqlConnection to PgConnection. This is mostly useful for Vert.x generated APIs like RxJava/Mutiny.
      Parameters:
      sqlConnection - the connection to cast
      Returns:
      a instance