Class PgConnection

All Implemented Interfaces:
MutinyDelegate

public class PgConnection extends SqlConnection implements MutinyDelegate
A connection to Postgres.

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

  • Notification
  • Request Cancellation

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

Author:
Julien Viet, Emad Alblueshi
See Also:
  • PgConnection
  • Field Details

  • Constructor Details

    • PgConnection

      public PgConnection(io.vertx.pgclient.PgConnection delegate)
      Create a new instance of PgConnection delegating to the given (non-null) instance of PgConnection.
    • PgConnection

      public PgConnection(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.pgclient.PgConnection getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Overrides:
      getDelegate in class SqlConnection
      Returns:
      the delegate instance
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx, io.vertx.pgclient.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.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      vertx - the vertx instance
      options - the connect options
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, PgConnectOptions)
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx, io.vertx.pgclient.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.

      Unlike the bare Vert.x variant, this method returns a PgConnection. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Parameters:
      vertx - the vertx instance
      options - the connect options
      Returns:
      The operation result
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, PgConnectOptions)
    • connectAndForget

      public static void connectAndForget(Vertx vertx, io.vertx.pgclient.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.

      Unlike the bare Vert.x variant, this method ignores the PgConnection result or any failure.

      Parameters:
      vertx - the vertx instance
      options - the connect options
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, PgConnectOptions)
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx)
      Like connect(Vertx, PgConnectOptions) with options build from the environment variables.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx)
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx)
      Like connect(Vertx, PgConnectOptions) with options build from the environment variables.

      Unlike the bare Vert.x variant, this method returns a PgConnection. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      The operation result
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx)
    • connectAndForget

      public static void connectAndForget(Vertx vertx)
      Like connect(Vertx, PgConnectOptions) with options build from the environment variables.

      Unlike the bare Vert.x variant, this method ignores the PgConnection result or any failure.

      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx)
    • connect

      @CheckReturnValue public static io.smallrye.mutiny.Uni<PgConnection> connect(Vertx vertx, String connectionUri)
      Like connect(Vertx, PgConnectOptions) with options build from connectionUri.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, String)
    • connectAndAwait

      public static PgConnection connectAndAwait(Vertx vertx, String connectionUri)
      Like connect(Vertx, PgConnectOptions) with options build from connectionUri.

      Unlike the bare Vert.x variant, this method returns a PgConnection. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Returns:
      The operation result
      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, String)
    • connectAndForget

      public static void connectAndForget(Vertx vertx, String connectionUri)
      Like connect(Vertx, PgConnectOptions) with options build from connectionUri.

      Unlike the bare Vert.x variant, this method ignores the PgConnection result or any failure.

      See Also:
      • io.vertx.pgclient.PgConnection#connect(Vertx, String)
    • cancelRequest

      @CheckReturnValue public io.smallrye.mutiny.Uni<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.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • PgConnection.cancelRequest()
    • cancelRequestAndAwait

      public void cancelRequestAndAwait()
      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.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      See Also:
      • PgConnection.cancelRequest()
    • cancelRequestAndForget

      public PgConnection cancelRequestAndForget()
      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.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • PgConnection.cancelRequest()
    • prepare

      @CheckReturnValue public io.smallrye.mutiny.Uni<PreparedStatement> prepare(String sql)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Overrides:
      prepare in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • SqlConnection.prepare(String)
    • prepareAndAwait

      public PreparedStatement prepareAndAwait(String sql)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method returns a PreparedStatement. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      prepareAndAwait in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      The operation result
      See Also:
      • SqlConnection.prepare(String)
    • prepareAndForget

      public PgConnection prepareAndForget(String sql)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method ignores the PreparedStatement result or any failure.

      Overrides:
      prepareAndForget in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • SqlConnection.prepare(String)
    • close

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> close()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Overrides:
      close in class SqlConnection
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • SqlClient.close()
    • closeAndAwait

      public void closeAndAwait()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      closeAndAwait in class SqlConnection
      See Also:
      • SqlClient.close()
    • closeAndForget

      public PgConnection closeAndForget()
      Close the client and release the associated resources.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Overrides:
      closeAndForget in class SqlConnection
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • SqlClient.close()
    • begin

      @CheckReturnValue public io.smallrye.mutiny.Uni<Transaction> begin()
      Begin a transaction and returns a Transaction for controlling and tracking this transaction.

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

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Overrides:
      begin in class SqlConnection
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • SqlConnection.begin()
    • beginAndAwait

      public Transaction beginAndAwait()
      Begin a transaction and returns a Transaction for controlling and tracking this transaction.

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

      Unlike the bare Vert.x variant, this method returns a Transaction. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      beginAndAwait in class SqlConnection
      Returns:
      The operation result
      See Also:
      • SqlConnection.begin()
    • beginAndForget

      public PgConnection beginAndForget()
      Begin a transaction and returns a Transaction for controlling and tracking this transaction.

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

      Unlike the bare Vert.x variant, this method ignores the Transaction result or any failure.

      Overrides:
      beginAndForget in class SqlConnection
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • SqlConnection.begin()
    • prepare

      @CheckReturnValue public io.smallrye.mutiny.Uni<PreparedStatement> prepare(String sql, io.vertx.sqlclient.PrepareOptions options)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Overrides:
      prepare in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • SqlConnection.prepare(String, PrepareOptions)
    • prepareAndAwait

      public PreparedStatement prepareAndAwait(String sql, io.vertx.sqlclient.PrepareOptions options)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method returns a PreparedStatement. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

      Overrides:
      prepareAndAwait in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      The operation result
      See Also:
      • SqlConnection.prepare(String, PrepareOptions)
    • prepareAndForget

      public PgConnection prepareAndForget(String sql, io.vertx.sqlclient.PrepareOptions options)
      Create a prepared statement using the given sql string.

      Unlike the bare Vert.x variant, this method ignores the PreparedStatement result or any failure.

      Overrides:
      prepareAndForget in class SqlConnection
      Parameters:
      sql - the sql
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • SqlConnection.prepare(String, PrepareOptions)
    • notificationHandler

      public PgConnection notificationHandler(Consumer<io.vertx.pgclient.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

      public PgConnection noticeHandler(Consumer<io.vertx.pgclient.PgNotice> handler)
      Set a handler called when the connection receives a notice from the server.
      Parameters:
      handler -
      Returns:
    • processId

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

      public int secretKey()
      Returns:
      The secret key for the target backend
    • exceptionHandler

      public PgConnection exceptionHandler(Consumer<Throwable> handler)
      Set an handler called with connection errors.
      Overrides:
      exceptionHandler in class SqlConnection
      Parameters:
      handler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • closeHandler

      public PgConnection closeHandler(Runnable handler)
      Set an handler called when the connection is closed.
      Overrides:
      closeHandler in class SqlConnection
      Parameters:
      handler - the handler
      Returns:
      a reference to this, so the API can be used fluently
    • cast

      public 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
    • newInstance

      public static PgConnection newInstance(io.vertx.pgclient.PgConnection delegate)
      Creates a new instance of the PgConnection.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class SqlConnection
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class SqlConnection
    • toString

      public String toString()
      Overrides:
      toString in class SqlConnection