Package org.postgresql.core
Interface BaseConnection
-
- All Superinterfaces:
java.lang.AutoCloseable,java.sql.Connection,PGConnection,java.sql.Wrapper
- All Known Implementing Classes:
PgConnection
public interface BaseConnection extends PGConnection, java.sql.Connection
Driver-internal connection interface. Application code should not use this interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddTimerTask(java.util.TimerTask timerTask, long milliSeconds)Schedule a TimerTask for later execution.booleanbinaryTransferSend(int oid)Returns true if value for the given oid should be sent using binary transfer.voidcancelQuery()Cancel the current query executing on this connection.CachedQuerycreateQuery(java.lang.String sql, boolean escapeProcessing, boolean isParameterized, java.lang.String... columnNames)byte[]encodeString(java.lang.String str)Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions).java.lang.StringescapeString(java.lang.String str)Escapes a string for use as string-literal within an SQL command.java.sql.ResultSetexecSQLQuery(java.lang.String s)Execute a SQL query that returns a single resultset.java.sql.ResultSetexecSQLQuery(java.lang.String s, int resultSetType, int resultSetConcurrency)voidexecSQLUpdate(java.lang.String s)Execute a SQL query that does not return results.EncodinggetEncoding()LruCache<FieldMetadata.Key,FieldMetadata>getFieldMetadataCache()Return metadata cache for given connection.java.util.logging.LoggergetLogger()booleangetLogServerErrorDetail()Indicates if error details from server used in included in logging and exceptions.java.lang.ObjectgetObject(java.lang.String type, java.lang.String value, byte[] byteValue)Construct and return an appropriate object for the given type and value.QueryExecutorgetQueryExecutor()Get the QueryExecutor implementation for this connection.ReplicationProtocolgetReplicationProtocol()Internal protocol for work with physical and logical replication.booleangetStandardConformingStrings()Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.booleangetStringVarcharFlag()TimestampUtilsgetTimestampUtils()TransactionStategetTransactionState()Get the current transaction state of this connection.TypeInfogetTypeInfo()PGXmlFactoryFactorygetXmlFactoryFactory()Retrieve the factory to instantiate XML processing factories.booleanhaveMinimumServerVersion(int ver)Check if we have at least a particular server version.booleanhaveMinimumServerVersion(Version ver)Check if we have at least a particular server version.booleanhintReadOnly()Indicates if statements to backend should be hinted as read only.booleanisColumnSanitiserDisabled()Return whether to disable column name sanitation.voidpurgeTimerTasks()Invoke purge() on the underlying shared Timer so that internal resources will be released.voidsetFlushCacheOnDeallocate(boolean flushCacheOnDeallocate)By default, the connection resets statement cache in case deallocate all/discard all message is observed.-
Methods inherited from interface java.sql.Connection
abort, beginRequest, clearWarnings, close, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, endRequest, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTransactionIsolation, setTypeMap
-
Methods inherited from interface org.postgresql.PGConnection
addDataType, addDataType, createArrayOf, escapeIdentifier, escapeLiteral, getAutosave, getBackendPID, getCopyAPI, getDefaultFetchSize, getFastpathAPI, getLargeObjectAPI, getNotifications, getNotifications, getParameterStatus, getParameterStatuses, getPreferQueryMode, getPrepareThreshold, getReplicationAPI, setAutosave, setDefaultFetchSize, setPrepareThreshold
-
-
-
-
Method Detail
-
cancelQuery
void cancelQuery() throws java.sql.SQLExceptionCancel the current query executing on this connection.- Specified by:
cancelQueryin interfacePGConnection- Throws:
java.sql.SQLException- if something goes wrong.
-
execSQLQuery
java.sql.ResultSet execSQLQuery(java.lang.String s) throws java.sql.SQLExceptionExecute a SQL query that returns a single resultset. Never causes a new transaction to be started regardless of the autocommit setting.- Parameters:
s- the query to execute- Returns:
- the (non-null) returned resultset
- Throws:
java.sql.SQLException- if something goes wrong.
-
execSQLQuery
java.sql.ResultSet execSQLQuery(java.lang.String s, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
execSQLUpdate
void execSQLUpdate(java.lang.String s) throws java.sql.SQLExceptionExecute a SQL query that does not return results. Never causes a new transaction to be started regardless of the autocommit setting.- Parameters:
s- the query to execute- Throws:
java.sql.SQLException- if something goes wrong.
-
getQueryExecutor
QueryExecutor getQueryExecutor()
Get the QueryExecutor implementation for this connection.- Returns:
- the (non-null) executor
-
getReplicationProtocol
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:
- not null replication protocol
-
getObject
java.lang.Object getObject(java.lang.String type, java.lang.String value, byte[] byteValue) throws java.sql.SQLExceptionConstruct and return an appropriate object for the given type and value. This only considers the types registered via
PGConnection.addDataType(String, Class)andPGConnection.addDataType(String, String).If no class is registered as handling the given type, then a generic
PGobjectinstance is returned.value or byteValue must be non-null
- Parameters:
type- the backend typenamevalue- the type-specific string representation of the valuebyteValue- the type-specific binary representation of the value- Returns:
- an appropriate object; never null.
- Throws:
java.sql.SQLException- if something goes wrong
-
getEncoding
Encoding getEncoding() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
getTypeInfo
TypeInfo getTypeInfo()
-
haveMinimumServerVersion
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- the server version to check, of the form xxyyzz eg 90401- Returns:
- true if the server version is at least "ver".
-
haveMinimumServerVersion
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- the server version to check- Returns:
- true if the server version is at least "ver".
-
encodeString
byte[] encodeString(java.lang.String str) throws java.sql.SQLExceptionEncode 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- the string to encode- Returns:
- an encoded representation of the string
- Throws:
java.sql.SQLException- if something goes wrong.
-
escapeString
java.lang.String escapeString(java.lang.String str) throws java.sql.SQLExceptionEscapes a string for use as string-literal within an SQL command. The method chooses the applicable escaping rules based on the value ofgetStandardConformingStrings().- Parameters:
str- a string value- Returns:
- the escaped representation of the string
- Throws:
java.sql.SQLException- if the string contains a\0character
-
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 thestandard_conforming_stringsserver variable.- Returns:
- true if the server treats string literals according to the SQL standard
- See Also:
QueryExecutor.getStandardConformingStrings()
-
getTimestampUtils
TimestampUtils getTimestampUtils()
-
getLogger
java.util.logging.Logger getLogger()
-
getStringVarcharFlag
boolean getStringVarcharFlag()
-
getTransactionState
TransactionState getTransactionState()
Get the current transaction state of this connection.- Returns:
- current transaction state of this connection
-
binaryTransferSend
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- The oid to check.- Returns:
- True for binary transfer, false for text transfer.
-
isColumnSanitiserDisabled
boolean isColumnSanitiserDisabled()
Return whether to disable column name sanitation.- Returns:
- true column sanitizer is disabled
-
addTimerTask
void addTimerTask(java.util.TimerTask timerTask, long milliSeconds)Schedule a TimerTask for later execution. The task will be scheduled with the shared Timer for this connection.- Parameters:
timerTask- timer task to schedulemilliSeconds- delay in milliseconds
-
purgeTimerTasks
void purgeTimerTasks()
Invoke purge() on the underlying shared Timer so that internal resources will be released.
-
getFieldMetadataCache
LruCache<FieldMetadata.Key,FieldMetadata> getFieldMetadataCache()
Return metadata cache for given connection.- Returns:
- metadata cache
-
createQuery
CachedQuery createQuery(java.lang.String sql, boolean escapeProcessing, boolean isParameterized, java.lang.String... columnNames) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
setFlushCacheOnDeallocate
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- true if statement cache should be reset when "deallocate/discard" message observed
-
hintReadOnly
boolean hintReadOnly()
Indicates if statements to backend should be hinted as read only.- Returns:
- Indication if hints to backend (such as when transaction begins) should be read only.
- See Also:
PGProperty.READ_ONLY_MODE
-
getXmlFactoryFactory
PGXmlFactoryFactory getXmlFactoryFactory() throws java.sql.SQLException
Retrieve the factory to instantiate XML processing factories.- Returns:
- The factory to use to instantiate XML processing factories
- Throws:
java.sql.SQLException- if the class cannot be found or instantiated.
-
getLogServerErrorDetail
boolean getLogServerErrorDetail()
Indicates if error details from server used in included in logging and exceptions.- Returns:
- true if should be included and passed on to other exceptions
-
-