Package io.vertx.rxjava.pgclient
Class PgConnection
- java.lang.Object
-
- io.vertx.rxjava.sqlclient.SqlClient
-
- io.vertx.rxjava.sqlclient.SqlConnection
-
- io.vertx.rxjava.pgclient.PgConnection
-
public class PgConnection extends SqlConnection
A connection to Postgres.The connection object supports all the operations defined in the interface, it also provides additional support:
- Notification
- Request Cancellation
original
non RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<PgConnection>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description PgConnection(io.vertx.pgclient.PgConnection delegate)
PgConnection(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PgConnection
cancelRequest(io.vertx.core.Handler<io.vertx.core.AsyncResult<Void>> handler)
Send a request cancellation message to tell the server to cancel processing request in this connection.static PgConnection
cast(SqlConnection sqlConnection)
Cast a toPgConnection
.PgConnection
closeHandler(io.vertx.core.Handler<Void> handler)
Set an handler called when the connection is closed.static void
connect(Vertx vertx)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.static void
connect(Vertx vertx, io.vertx.core.Handler<io.vertx.core.AsyncResult<PgConnection>> handler)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.static void
connect(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
Connects to the database and returns the connection if that succeeds.static void
connect(Vertx vertx, io.vertx.pgclient.PgConnectOptions options, io.vertx.core.Handler<io.vertx.core.AsyncResult<PgConnection>> handler)
Connects to the database and returns the connection if that succeeds.static void
connect(Vertx vertx, String connectionUri)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.static void
connect(Vertx vertx, String connectionUri, io.vertx.core.Handler<io.vertx.core.AsyncResult<PgConnection>> handler)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.boolean
equals(Object o)
PgConnection
exceptionHandler(io.vertx.core.Handler<Throwable> handler)
Set an handler called with connection errors.io.vertx.pgclient.PgConnection
getDelegate()
int
hashCode()
static PgConnection
newInstance(io.vertx.pgclient.PgConnection arg)
PgConnection
noticeHandler(io.vertx.core.Handler<io.vertx.pgclient.PgNotice> handler)
Set a handler called when the connection receives a notice from the server.PgConnection
notificationHandler(io.vertx.core.Handler<io.vertx.pgclient.PgNotification> handler)
Set a handler called when the connection receives notification on a channel.PgConnection
prepare(String sql)
Create a prepared statement using the givensql
string.PgConnection
prepare(String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<PreparedStatement>> handler)
Create a prepared statement using the givensql
string.int
processId()
static rx.Single<PgConnection>
rxConnect(Vertx vertx)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.static rx.Single<PgConnection>
rxConnect(Vertx vertx, io.vertx.pgclient.PgConnectOptions options)
Connects to the database and returns the connection if that succeeds.static rx.Single<PgConnection>
rxConnect(Vertx vertx, String connectionUri)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.rx.Single<PreparedStatement>
rxPrepare(String sql)
Create a prepared statement using the givensql
string.int
secretKey()
String
toString()
-
Methods inherited from class io.vertx.rxjava.sqlclient.SqlConnection
begin, begin, close, close, databaseMetadata, isSSL, newInstance, prepare, prepare, rxBegin, rxClose, rxPrepare, transaction
-
Methods inherited from class io.vertx.rxjava.sqlclient.SqlClient
newInstance, preparedQuery, preparedQuery, query
-
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<PgConnection> __TYPE_ARG
-
-
Constructor Detail
-
PgConnection
public PgConnection(io.vertx.pgclient.PgConnection delegate)
-
PgConnection
public PgConnection(Object delegate)
-
-
Method Detail
-
toString
public String toString()
- Overrides:
toString
in classSqlConnection
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classSqlConnection
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classSqlConnection
-
getDelegate
public io.vertx.pgclient.PgConnection getDelegate()
- Overrides:
getDelegate
in classSqlConnection
-
connect
public static void connect(Vertx vertx, io.vertx.pgclient.PgConnectOptions options, io.vertx.core.Handler<io.vertx.core.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 instanceoptions
- the connect optionshandler
- the handler called with the connection or the failure
-
connect
public static void 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.- Parameters:
vertx
- the vertx instanceoptions
- the connect options
-
rxConnect
public static rx.Single<PgConnection> rxConnect(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.- Parameters:
vertx
- the vertx instanceoptions
- the connect options- Returns:
-
connect
public static void connect(Vertx vertx, io.vertx.core.Handler<io.vertx.core.AsyncResult<PgConnection>> handler)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.- Parameters:
vertx
-handler
-
-
connect
public static void connect(Vertx vertx)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.- Parameters:
vertx
-
-
rxConnect
public static rx.Single<PgConnection> rxConnect(Vertx vertx)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build from the environment variables.- Parameters:
vertx
-- Returns:
-
connect
public static void connect(Vertx vertx, String connectionUri, io.vertx.core.Handler<io.vertx.core.AsyncResult<PgConnection>> handler)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.- Parameters:
vertx
-connectionUri
-handler
-
-
connect
public static void connect(Vertx vertx, String connectionUri)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.- Parameters:
vertx
-connectionUri
-
-
rxConnect
public static rx.Single<PgConnection> rxConnect(Vertx vertx, String connectionUri)
Likeconnect(io.vertx.rxjava.core.Vertx, io.vertx.pgclient.PgConnectOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.rxjava.pgclient.PgConnection>>)
with options build fromconnectionUri
.- Parameters:
vertx
-connectionUri
-- Returns:
-
notificationHandler
public PgConnection notificationHandler(io.vertx.core.Handler<io.vertx.pgclient.PgNotification> handler)
Set a handler called when the connection receives notification on a channel. The handler is called with thePgNotification
and has access to the channel name and the notification payload.- Parameters:
handler
- the handler- Returns:
- the transaction instance
-
noticeHandler
public PgConnection noticeHandler(io.vertx.core.Handler<io.vertx.pgclient.PgNotice> handler)
Set a handler called when the connection receives a notice from the server.- Parameters:
handler
-- Returns:
-
cancelRequest
public PgConnection cancelRequest(io.vertx.core.Handler<io.vertx.core.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
public int processId()
- Returns:
- The process ID of the target backend
-
secretKey
public int secretKey()
- Returns:
- The secret key for the target backend
-
prepare
public PgConnection prepare(String sql, io.vertx.core.Handler<io.vertx.core.AsyncResult<PreparedStatement>> handler)
Description copied from class:SqlConnection
Create a prepared statement using the givensql
string.- Overrides:
prepare
in classSqlConnection
- Parameters:
sql
-handler
-- Returns:
-
prepare
public PgConnection prepare(String sql)
Description copied from class:SqlConnection
Create a prepared statement using the givensql
string.- Overrides:
prepare
in classSqlConnection
- Parameters:
sql
-- Returns:
-
rxPrepare
public rx.Single<PreparedStatement> rxPrepare(String sql)
Description copied from class:SqlConnection
Create a prepared statement using the givensql
string.- Overrides:
rxPrepare
in classSqlConnection
- Parameters:
sql
-- Returns:
-
exceptionHandler
public PgConnection exceptionHandler(io.vertx.core.Handler<Throwable> handler)
Description copied from class:SqlConnection
Set an handler called with connection errors.- Overrides:
exceptionHandler
in classSqlConnection
- Parameters:
handler
-- Returns:
-
closeHandler
public PgConnection closeHandler(io.vertx.core.Handler<Void> handler)
Description copied from class:SqlConnection
Set an handler called when the connection is closed.- Overrides:
closeHandler
in classSqlConnection
- Parameters:
handler
-- Returns:
-
cast
public static PgConnection cast(SqlConnection sqlConnection)
Cast a toPgConnection
. 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 arg)
-
-