Interface PgConnection
- All Superinterfaces:
SqlClient, 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
Modifier and TypeMethodDescriptionSend a request cancellation message to tell the server to cancel processing request in this connection.static PgConnectioncast(SqlConnection sqlConnection) Cast aSqlConnectiontoPgConnection.closeHandler(Handler<Void> handler) Set an handler called when the connection is closed.static Future<PgConnection> Likeconnect(Vertx, PgConnectOptions)with options build from the environment variables.static Future<PgConnection> connect(Vertx vertx, PgConnectOptions options) Connects to the database and returns the connection if that succeeds.static Future<PgConnection> Likeconnect(Vertx, PgConnectOptions)with options build fromconnectionUri.exceptionHandler(Handler<Throwable> handler) Set an handler called with connection errors.noticeHandler(Handler<PgNotice> handler) Set a handler called when the connection receives a notice from the server.notificationHandler(Handler<PgNotification> handler) Set a handler called when the connection receives notification on a channel.intintMethods inherited from interface SqlClient
close, preparedQuery, preparedQuery, queryMethods inherited from interface SqlConnection
begin, databaseMetadata, isSSL, prepare, prepare, transaction
-
Method Details
-
connect
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 instanceoptions- the connect options- Returns:
- a future notified with the connection or the failure
-
connect
Likeconnect(Vertx, PgConnectOptions)with options build from the environment variables. -
connect
Likeconnect(Vertx, PgConnectOptions)with options build fromconnectionUri. -
notificationHandler
Set a handler called when the connection receives notification on a channel. The handler is called with thePgNotificationand has access to the channel name and the notification payload.- Parameters:
handler- the handler- Returns:
- the transaction instance
-
noticeHandler
Set a handler called when the connection receives a notice from the server.- Parameters:
handler-- Returns:
-
cancelRequest
-
processId
int processId()- Returns:
- The process ID of the target backend
-
secretKey
int secretKey()- Returns:
- The secret key for the target backend
-
exceptionHandler
Set an handler called with connection errors.- Specified by:
exceptionHandlerin interfaceSqlConnection- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
Set an handler called when the connection is closed.- Specified by:
closeHandlerin interfaceSqlConnection- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
cast
Cast aSqlConnectiontoPgConnection. This is mostly useful for Vert.x generated APIs like RxJava/Mutiny.- Parameters:
sqlConnection- the connection to cast- Returns:
- a
instance
-