Top Description Fields Methods
org.postgresql.core

public Interface BaseConnection

extends PGConnection, Connection
Known Direct Implementers
org.postgresql.jdbc.PgConnection
Imports
org.postgresql.PGConnection, .PGProperty, org.postgresql.jdbc.FieldMetadata, .TimestampUtils, org.postgresql.util.LruCache, org.postgresql.xml.PGXmlFactoryFactory, org.checkerframework.checker.nullness.qual.Nullable, .PolyNull, org.checkerframework.dataflow.qual.Pure, java.sql.Connection, .ResultSet, .SQLException, java.util.TimerTask, java.util.logging.Logger

Driver-internal connection interface. Application code should not use this interface.

Field Summary

Inherited from java.sql.Connection:
TRANSACTION_NONETRANSACTION_READ_COMMITTEDTRANSACTION_READ_UNCOMMITTEDTRANSACTION_REPEATABLE_READTRANSACTION_SERIALIZABLE

Method Summary

Modifier and TypeMethod and Description
public void
addTimerTask(TimerTask
timer task to schedule
timerTask
,
long
delay in milliseconds
milliSeconds
)

Schedule a TimerTask for later execution.

public boolean

Returns:

True for binary transfer, false for text transfer.
binaryTransferSend
(int
The oid to check.
oid
)

Returns true if value for the given oid should be sent using binary transfer.

public void
cancelQuery()

Redeclares org.postgresql.PGConnection.cancelQuery.

Cancel the current query executing on this connection.

public CachedQuery
createQuery(String sql, boolean escapeProcessing, boolean isParameterized, String... columnNames)

public @PolyNull byte[]

Returns:

an encoded representation of the string
encodeString
(@PolyNull String
the string to encode
str
)

Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions).

public String

Returns:

the escaped representation of the string
escapeString
(String
a string value
str
)

Escapes a string for use as string-literal within an SQL command.

public ResultSet

Returns:

the (non-null) returned resultset
execSQLQuery
(String
the query to execute
s
)

Execute a SQL query that returns a single resultset.

public ResultSet
execSQLQuery(String s, int resultSetType, int resultSetConcurrency)

public void
execSQLUpdate(String
the query to execute
s
)

Execute a SQL query that does not return results.

public Encoding
public LruCache<FieldMetadata.Key, FieldMetadata>

Returns:

metadata cache
getFieldMetadataCache
()

Return metadata cache for given connection.

public Logger
public boolean

Returns:

true if should be included and passed on to other exceptions
getLogServerErrorDetail
()

Indicates if error details from server used in included in logging and exceptions.

public Object

Returns:

an appropriate object; never null.
getObject
(String
the backend typename
type
,
@Nullable String
the type-specific string representation of the value
value
,
@Nullable byte[]
the type-specific binary representation of the value
byteValue
)

Construct and return an appropriate object for the given type and value.

public QueryExecutor

Returns:

the (non-null) executor
getQueryExecutor
()

Get the QueryExecutor implementation for this connection.

public ReplicationProtocol

Returns:

not null replication protocol
getReplicationProtocol
()

Internal protocol for work with physical and logical replication.

public boolean

Returns:

true if the server treats string literals according to the SQL standard
getStandardConformingStrings
()

Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.

public boolean
public TimestampUtils
getTimestampUtils()
Deprecated

public TransactionState

Returns:

current transaction state of this connection
getTransactionState
()

Get the current transaction state of this connection.

public TypeInfo
public PGXmlFactoryFactory

Returns:

The factory to use to instantiate XML processing factories
getXmlFactoryFactory
()

Retrieve the factory to instantiate XML processing factories.

public boolean

Returns:

true if the server version is at least "ver".
haveMinimumServerVersion
(int
the server version to check, of the form xxyyzz eg 90401
ver
)

Check if we have at least a particular server version.

public boolean

Returns:

true if the server version is at least "ver".
haveMinimumServerVersion
(Version
the server version to check
ver
)

Check if we have at least a particular server version.

public boolean

Returns:

Indication if hints to backend (such as when transaction begins) should be read only.
hintReadOnly
()

Indicates if statements to backend should be hinted as read only.

public boolean

Returns:

true column sanitizer is disabled
isColumnSanitiserDisabled
()

Return whether to disable column name sanitation.

public void
purgeTimerTasks()

Invoke purge() on the underlying shared Timer so that internal resources will be released.

public void
setFlushCacheOnDeallocate(boolean
true if statement cache should be reset when "deallocate/discard" message observed
flushCacheOnDeallocate
)

By default, the connection resets statement cache in case deallocate all/discard all message is observed.

Inherited from java.sql.Connection:
abortbeginRequestclearWarningsclosecommitcreateArrayOfcreateBlobcreateClobcreateNClobcreateSQLXMLcreateStatementcreateStatementcreateStatementcreateStructendRequestgetAutoCommitgetCataloggetClientInfogetClientInfogetHoldabilitygetMetaDatagetNetworkTimeoutgetSchemagetTransactionIsolationgetTypeMapgetWarningsisClosedisReadOnlyisValidnativeSQLprepareCallprepareCallprepareCallprepareStatementprepareStatementprepareStatementprepareStatementprepareStatementprepareStatementreleaseSavepointrollbackrollbacksetAutoCommitsetCatalogsetClientInfosetClientInfosetHoldabilitysetNetworkTimeoutsetReadOnlysetSavepointsetSavepointsetSchemasetShardingKeysetShardingKeysetShardingKeyIfValidsetShardingKeyIfValidsetTransactionIsolationsetTypeMap
Inherited from org.postgresql.PGConnection:
addDataTypeaddDataTypealterUserPasswordcreateArrayOfescapeIdentifierescapeLiteralgetAdaptiveFetchgetAutosavegetBackendPIDgetCopyAPIgetDefaultFetchSizegetFastpathAPIgetLargeObjectAPIgetNotificationsgetNotificationsgetParameterStatusgetParameterStatusesgetPreferQueryModegetPrepareThresholdgetReplicationAPIsetAdaptiveFetchsetAutosavesetDefaultFetchSizesetPrepareThreshold

Method Detail

addTimerTaskback to summary
public void addTimerTask(TimerTask timerTask, long milliSeconds)

Schedule a TimerTask for later execution. The task will be scheduled with the shared Timer for this connection.

Parameters
timerTask:TimerTask

timer task to schedule

milliSeconds:long

delay in milliseconds

binaryTransferSendback to summary
public boolean binaryTransferSend(int oid)

Returns true if value for the given oid should be sent using binary transfer. False if value should be sent using text transfer.

Parameters
oid:int

The oid to check.

Returns:boolean

True for binary transfer, false for text transfer.

cancelQueryback to summary
public void cancelQuery() throws SQLException

Redeclares org.postgresql.PGConnection.cancelQuery.

Cancel the current query executing on this connection.

Annotations
@Override
Exceptions
SQLException:
if something goes wrong.
createQueryback to summary
public CachedQuery createQuery(String sql, boolean escapeProcessing, boolean isParameterized, String... columnNames) throws SQLException
encodeStringback to summary
public @PolyNull byte[] encodeString(@PolyNull String str) throws SQLException

Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions). This is used when constructing synthetic resultsets (for example, in metadata methods).

Parameters
str:@PolyNull String

the string to encode

Returns:@PolyNull byte[]

an encoded representation of the string

Exceptions
SQLException:
if something goes wrong.
escapeStringback to summary
public String escapeString(String str) throws SQLException

Escapes a string for use as string-literal within an SQL command. The method chooses the applicable escaping rules based on the value of getStandardConformingStrings().

Parameters
str:String

a string value

Returns:String

the escaped representation of the string

Exceptions
SQLException:
if the string contains a \0 character
execSQLQueryback to summary
public ResultSet execSQLQuery(String s) throws SQLException

Execute a SQL query that returns a single resultset. Never causes a new transaction to be started regardless of the autocommit setting.

Parameters
s:String

the query to execute

Returns:ResultSet

the (non-null) returned resultset

Exceptions
SQLException:
if something goes wrong.
execSQLQueryback to summary
public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException
execSQLUpdateback to summary
public void execSQLUpdate(String s) throws SQLException

Execute a SQL query that does not return results. Never causes a new transaction to be started regardless of the autocommit setting.

Parameters
s:String

the query to execute

Exceptions
SQLException:
if something goes wrong.
getEncodingback to summary
public Encoding getEncoding() throws SQLException
Annotations
@Pure
getFieldMetadataCacheback to summary
public LruCache<FieldMetadata.Key, FieldMetadata> getFieldMetadataCache()

Return metadata cache for given connection.

Returns:LruCache<FieldMetadata.Key, FieldMetadata>

metadata cache

getLoggerback to summary
public Logger getLogger()
getLogServerErrorDetailback to summary
public boolean getLogServerErrorDetail()

Indicates if error details from server used in included in logging and exceptions.

Returns:boolean

true if should be included and passed on to other exceptions

getObjectback to summary
public Object getObject(String type, @Nullable String value, @Nullable byte[] byteValue) throws SQLException

Construct and return an appropriate object for the given type and value. This only considers the types registered via org.postgresql.PGConnection#addDataType(String, Class) and org.postgresql.PGConnection#addDataType(String, String).

If no class is registered as handling the given type, then a generic org.postgresql.util.PGobject instance is returned.

value or byteValue must be non-null

Parameters
type:String

the backend typename

value:@Nullable String

the type-specific string representation of the value

byteValue:@Nullable byte[]

the type-specific binary representation of the value

Returns:Object

an appropriate object; never null.

Exceptions
SQLException:
if something goes wrong
getQueryExecutorback to summary
public QueryExecutor getQueryExecutor()

Get the QueryExecutor implementation for this connection.

Returns:QueryExecutor

the (non-null) executor

getReplicationProtocolback to summary
public ReplicationProtocol getReplicationProtocol()

Internal protocol for work with physical and logical replication. Physical replication available only since PostgreSQL version 9.1. Logical replication available only since PostgreSQL version 9.4.

Returns:ReplicationProtocol

not null replication protocol

getStandardConformingStringsback to summary
public 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:boolean

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

See Also
QueryExecutor#getStandardConformingStrings()
getStringVarcharFlagback to summary
public boolean getStringVarcharFlag()
getTimestampUtilsback to summary
public TimestampUtils getTimestampUtils()

Deprecated

Annotations
@Deprecated
getTransactionStateback to summary
public TransactionState getTransactionState()

Get the current transaction state of this connection.

Returns:TransactionState

current transaction state of this connection

getTypeInfoback to summary
public TypeInfo getTypeInfo()
getXmlFactoryFactoryback to summary
public PGXmlFactoryFactory getXmlFactoryFactory() throws SQLException

Retrieve the factory to instantiate XML processing factories.

Returns:PGXmlFactoryFactory

The factory to use to instantiate XML processing factories

Exceptions
SQLException:
if the class cannot be found or instantiated.
haveMinimumServerVersionback to summary
public boolean haveMinimumServerVersion(int ver)

Check if we have at least a particular server version.

The input version is of the form xxyyzz, matching a PostgreSQL version like xx.yy.zz. So 9.0.12 is 90012.

Parameters
ver:int

the server version to check, of the form xxyyzz eg 90401

Returns:boolean

true if the server version is at least "ver".

haveMinimumServerVersionback to summary
public boolean haveMinimumServerVersion(Version ver)

Check if we have at least a particular server version.

The input version is of the form xxyyzz, matching a PostgreSQL version like xx.yy.zz. So 9.0.12 is 90012.

Parameters
ver:Version

the server version to check

Returns:boolean

true if the server version is at least "ver".

hintReadOnlyback to summary
public boolean hintReadOnly()

Indicates if statements to backend should be hinted as read only.

Returns:boolean

Indication if hints to backend (such as when transaction begins) should be read only.

See Also
PGProperty#READ_ONLY_MODE
isColumnSanitiserDisabledback to summary
public boolean isColumnSanitiserDisabled()

Return whether to disable column name sanitation.

Returns:boolean

true column sanitizer is disabled

purgeTimerTasksback to summary
public void purgeTimerTasks()

Invoke purge() on the underlying shared Timer so that internal resources will be released.

setFlushCacheOnDeallocateback to summary
public void setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate)

By default, the connection resets statement cache in case deallocate all/discard all message is observed. This API allows to disable that feature for testing purposes.

Parameters
flushCacheOnDeallocate:boolean

true if statement cache should be reset when "deallocate/discard" message observed