org.postgresql.core
Interface ProtocolConnection


public interface ProtocolConnection

Provides access to protocol-level connection operations.

Author:
Oliver Jowett (oliver@opencloud.com)

Field Summary
static int TRANSACTION_FAILED
          Constant returned by getTransactionState() indicating that a transaction is currently open, but it has seen errors and will refuse subsequent queries until a ROLLBACK.
static int TRANSACTION_IDLE
          Constant returned by getTransactionState() indicating that no transaction is currently open.
static int TRANSACTION_OPEN
          Constant returned by getTransactionState() indicating that a transaction is currently open.
 
Method Summary
 void abort()
          Abort at network level without sending the Terminate message to the backend.
 void close()
          Close this connection cleanly.
 int getBackendPID()
          Return the process ID (PID) of the backend server process handling this connection.
 String getDatabase()
           
 Encoding getEncoding()
           
 HostSpec getHostSpec()
           
 boolean getIntegerDateTimes()
          Returns true if server uses integer instead of double for binary date and time encodings.
 PGNotification[] getNotifications()
          Retrieve and clear the set of asynchronous notifications pending on this connection.
 int getProtocolVersion()
           
 QueryExecutor getQueryExecutor()
           
 String getServerVersion()
          Return the server version from the server_version GUC.
 int getServerVersionNum()
          Get a machine-readable server version.
 boolean getStandardConformingStrings()
          Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.
 int getTransactionState()
          Get the current transaction state of this connection.
 String getUser()
           
 SQLWarning getWarnings()
          Retrieve and clear the chain of warnings accumulated on this connection.
 boolean isClosed()
          Check if this connection is closed.
 void sendQueryCancel()
          Sends a query cancellation for this connection.
 void setBinaryReceiveOids(Set<Integer> useBinaryForOids)
          Sets the oids that should be received using binary encoding.
 

Field Detail

TRANSACTION_IDLE

static final int TRANSACTION_IDLE
Constant returned by getTransactionState() indicating that no transaction is currently open.

See Also:
Constant Field Values

TRANSACTION_OPEN

static final int TRANSACTION_OPEN
Constant returned by getTransactionState() indicating that a transaction is currently open.

See Also:
Constant Field Values

TRANSACTION_FAILED

static final int TRANSACTION_FAILED
Constant returned by getTransactionState() indicating that a transaction is currently open, but it has seen errors and will refuse subsequent queries until a ROLLBACK.

See Also:
Constant Field Values
Method Detail

getHostSpec

HostSpec getHostSpec()
Returns:
the host and port this connection is connected to.

getUser

String getUser()
Returns:
the user this connection authenticated as.

getDatabase

String getDatabase()
Returns:
the database this connection is connected to.

getServerVersion

String getServerVersion()
Return the server version from the server_version GUC. Note that there's no requirement for this to be numeric or of the form x.y.z. PostgreSQL development releases usually have the format x.ydevel e.g. 9.4devel; betas usually x.ybetan e.g. 9.4beta1. The --with-extra-version configure option may add an arbitrary string to this. Don't use this string for logic, only use it when displaying the server version to the user. Prefer getServerVersionNum() for all logic purposes.

Returns:
the server version string from the server_version guc

getServerVersionNum

int getServerVersionNum()
Get a machine-readable server version. This returns the value of the server_version_num GUC. If no such GUC exists, it falls back on attempting to parse the text server version for the major version. If there's no minor version (e.g. a devel or beta release) then the minor version is set to zero. If the version could not be parsed, zero is returned.

Returns:
the server version in numeric XXYYZZ form, eg 090401, from server_version_num

getEncoding

Encoding getEncoding()
Returns:
the current encoding in use by this connection

getStandardConformingStrings

boolean getStandardConformingStrings()
Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules. Versions up to 8.1 always treated backslashes as escape characters in string-literals. Since 8.2, this depends on the value of the standard_conforming_strings server variable.

Returns:
true if the server treats string literals according to the SQL standard

getTransactionState

int getTransactionState()
Get the current transaction state of this connection.

Returns:
a ProtocolConnection.TRANSACTION_* constant.

getNotifications

PGNotification[] getNotifications()
                                  throws SQLException
Retrieve and clear the set of asynchronous notifications pending on this connection.

Returns:
an array of notifications; if there are no notifications, an empty array is returned.
Throws:
SQLException - if and error occurs while fetching notifications

getWarnings

SQLWarning getWarnings()
Retrieve and clear the chain of warnings accumulated on this connection.

Returns:
the first SQLWarning in the chain; subsequent warnings can be found via SQLWarning.getNextWarning().

getQueryExecutor

QueryExecutor getQueryExecutor()
Returns:
the QueryExecutor instance for this connection.

sendQueryCancel

void sendQueryCancel()
                     throws SQLException
Sends a query cancellation for this connection.

Throws:
SQLException - if something goes wrong.

close

void close()
Close this connection cleanly.


isClosed

boolean isClosed()
Check if this connection is closed.

Returns:
true iff the connection is closed.

getProtocolVersion

int getProtocolVersion()
Returns:
the version of the implementation

setBinaryReceiveOids

void setBinaryReceiveOids(Set<Integer> useBinaryForOids)
Sets the oids that should be received using binary encoding.

Parameters:
useBinaryForOids - The oids to request with binary encoding.

getIntegerDateTimes

boolean getIntegerDateTimes()
Returns true if server uses integer instead of double for binary date and time encodings.

Returns:
the server integer_datetime setting.

getBackendPID

int getBackendPID()
Return the process ID (PID) of the backend server process handling this connection.

Returns:
process ID (PID) of the backend server process handling this connection

abort

void abort()
Abort at network level without sending the Terminate message to the backend.



Copyright © 2016 PostgreSQL Global Development Group. All rights reserved.