Class PgConnection
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
,BaseConnection
,PGConnection
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
Default fetch size for statement.protected boolean
protected @Nullable DatabaseMetaData
protected int
The current type mappings.Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
abort()
void
void
addDataType
(String type, Class<? extends PGobject> klass) This allows client code to add a handler for one of org.postgresql's more unique data types.void
addDataType
(String type, String name) This allows client code to add a handler for one of org.postgresql's more unique data types.void
addTimerTask
(TimerTask timerTask, long milliSeconds) Schedule a TimerTask for later execution.void
addWarning
(SQLWarning warn) This adds a warning to the warning chain.boolean
binaryTransferSend
(int oid) Returns true if value for the given oid should be sent using binary transfer.void
Cancel the current query executing on this connection.protected void
void
void
close()
Note: even thoughStatement
is automatically closed when it is garbage collected, it is better to close it explicitly to lower resource consumption.void
commit()
createArrayOf
(String typeName, @Nullable Object elements) Creates anArray
wrapping elements.createArrayOf
(String typeName, @Nullable Object @Nullable [] elements) createQuery
(String sql, boolean escapeProcessing, boolean isParameterized, String... columnNames) <T> T
createQueryObject
(Class<T> ifc) createStatement
(int resultSetType, int resultSetConcurrency) createStatement
(int resultSetType, int resultSetConcurrency, int resultSetHoldability) createStruct
(String typeName, Object[] attributes) protected TypeInfo
createTypeInfo
(BaseConnection conn, int unknownLength) byte @PolyNull []
encodeString
(@PolyNull String str) Encode a string using the database's client_encoding (usually UTF8, but can vary on older server versions).escapeIdentifier
(String identifier) Return the given string suitably quoted to be used as an identifier in an SQL statement string.escapeLiteral
(String literal) Return the given string suitably quoted to be used as a string literal in an SQL statement string.escapeString
(String str) Escapes a string for use as string-literal within an SQL command.Execute a SQL query that returns a single resultset.execSQLQuery
(String s, int resultSetType, int resultSetConcurrency) void
Execute a SQL query that does not return results.boolean
Get state of adaptive fetch for connection.boolean
Connection configuration regarding automatic per-query savepoints.int
Return the process ID (PID) of the backend server process handling this connection.@Nullable String
getClientInfo
(String name) This returns the COPY API for the current connection.@Nullable String
getCursorName gets the cursor name.Get server version number.int
Get the default fetch size for statements created from this connection.This returns the Fastpath API for the current connection.Return metadata cache for given connection.boolean
boolean
int
protected @Nullable String
getIsolationLevelName
(int level) This returns the LargeObject API for the current connection.boolean
Indicates if error details from server used in included in logging and exceptions.int
This method returns any notifications that have been received since the last call to this method.getNotifications
(int timeoutMillis) This method returns any notifications that have been received since the last call to this method.Construct and return an appropriate object for the given type and value.final @Nullable String
getParameterStatus
(String parameterName) Shorthand for getParameterStatuses().get(...) .Returns the current values of all parameters reported by the server.Returns the query mode for this connection.int
Get the default server-side prepare reuse threshold for statements created from this connection.int
Get the QueryExecutor implementation for this connection.Internal protocol for work with physical and logical replication.@Nullable String
int
Get server major version.int
Get server minor version.boolean
Returns whether the server treats string-literals according to the SQL standard or if it uses traditional PostgreSQL escaping rules.boolean
Deprecated.int
Get the current transaction state of this connection.getURL()
We are required to bring back certain information by the DatabaseMetaData class.Method getUserName() brings back the User Name (again, we saved it).@Nullable SQLWarning
Retrieve the factory to instantiate XML processing factories.boolean
haveMinimumServerVersion
(int ver) Check if we have at least a particular server version.boolean
Check if we have at least a particular server version.boolean
Indicates if statements to backend should be hinted as read only.boolean
isClosed()
boolean
Return whether to disable column name sanitation.boolean
boolean
isValid
(int timeout) boolean
isWrapperFor
(Class<?> iface) protected Array
protected Blob
makeBlob
(long oid) protected Clob
makeClob
(long oid) protected SQLXML
prepareCall
(String sql) prepareCall
(String sql, int resultSetType, int resultSetConcurrency) prepareCall
(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement
(String sql) prepareStatement
(String sql, int autoGeneratedKeys) prepareStatement
(String sql, int @Nullable [] columnIndexes) prepareStatement
(String sql, int resultSetType, int resultSetConcurrency) prepareStatement
(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) prepareStatement
(String sql, String @Nullable [] columnNames) void
Invoke purge() on the underlying shared Timer so that internal resources will be released.void
releaseSavepoint
(Savepoint savepoint) void
rollback()
void
void
setAdaptiveFetch
(boolean adaptiveFetch) Turn on/off adaptive fetch for connection.void
setAutoCommit
(boolean autoCommit) void
setAutosave
(AutoSave autoSave) Configures if connection should use automatic savepoints.void
setCatalog
(String catalog) void
setClientInfo
(String name, @Nullable String value) void
setClientInfo
(Properties properties) void
setCursorName
(String cursor) In SQL, a result table can be retrieved through a cursor that is named.void
setDefaultFetchSize
(int fetchSize) Set the default fetch size for statements created from this connection.void
setDisableColumnSanitiser
(boolean disableColumnSanitiser) void
setFlushCacheOnDeallocate
(boolean flushCacheOnDeallocate) By default, the connection resets statement cache in case deallocate all/discard all message is observed.void
setForceBinary
(boolean newValue) void
setHoldability
(int holdability) void
setNetworkTimeout
(@Nullable Executor executor, int milliseconds) void
setPrepareThreshold
(int newThreshold) Set the default statement reuse threshold before enabling server-side prepare.void
setReadOnly
(boolean readOnly) setSavepoint
(String name) void
void
setTransactionIsolation
(int level) void
setTypeMap
(Map<String, Class<?>> map) void
setTypeMapImpl
(Map<String, Class<?>> map) <T> T
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
Methods inherited from interface org.postgresql.PGConnection
alterUserPassword
-
Field Details
-
prepareThreshold
protected int prepareThreshold -
defaultFetchSize
protected int defaultFetchSizeDefault fetch size for statement.- See Also:
-
forcebinary
protected boolean forcebinary -
typemap
The current type mappings. -
metadata
-
-
Constructor Details
-
PgConnection
- Throws:
SQLException
-
-
Method Details
-
createQuery
public CachedQuery createQuery(String sql, boolean escapeProcessing, boolean isParameterized, String... columnNames) throws SQLException - Specified by:
createQuery
in interfaceBaseConnection
- Throws:
SQLException
-
setFlushCacheOnDeallocate
public void setFlushCacheOnDeallocate(boolean flushCacheOnDeallocate) Description copied from interface:BaseConnection
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.- Specified by:
setFlushCacheOnDeallocate
in interfaceBaseConnection
- Parameters:
flushCacheOnDeallocate
- true if statement cache should be reset when "deallocate/discard" message observed
-
getTimestampUtils
Deprecated.- Specified by:
getTimestampUtils
in interfaceBaseConnection
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
getTypeMap
- Specified by:
getTypeMap
in interfaceConnection
- Throws:
SQLException
-
getQueryExecutor
Description copied from interface:BaseConnection
Get the QueryExecutor implementation for this connection.- Specified by:
getQueryExecutor
in interfaceBaseConnection
- Returns:
- the (non-null) executor
-
getReplicationProtocol
Description copied from interface:BaseConnection
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.- Specified by:
getReplicationProtocol
in interfaceBaseConnection
- Returns:
- not null replication protocol
-
addWarning
This adds a warning to the warning chain.- Parameters:
warn
- warning to add
-
execSQLQuery
Description copied from interface:BaseConnection
Execute a SQL query that returns a single resultset. Never causes a new transaction to be started regardless of the autocommit setting.- Specified by:
execSQLQuery
in interfaceBaseConnection
- Parameters:
s
- the query to execute- Returns:
- the (non-null) returned resultset
- Throws:
SQLException
- if something goes wrong.
-
execSQLQuery
public ResultSet execSQLQuery(String s, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
execSQLQuery
in interfaceBaseConnection
- Throws:
SQLException
-
execSQLUpdate
Description copied from interface:BaseConnection
Execute a SQL query that does not return results. Never causes a new transaction to be started regardless of the autocommit setting.- Specified by:
execSQLUpdate
in interfaceBaseConnection
- Parameters:
s
- the query to execute- Throws:
SQLException
- if something goes wrong.
-
setCursorName
In SQL, a result table can be retrieved through a cursor that is named. The current row of a result can be updated or deleted using a positioned update/delete statement that references the cursor name.
We do not support positioned update/delete, so this is a no-op.
- Parameters:
cursor
- the cursor name- Throws:
SQLException
- if a database access error occurs
-
getCursorName
getCursorName gets the cursor name.- Returns:
- the current cursor name
- Throws:
SQLException
- if a database access error occurs
-
getURL
We are required to bring back certain information by the DatabaseMetaData class. These functions do that.
Method getURL() brings back the URL (good job we saved it)
- Returns:
- the url
- Throws:
SQLException
- just in case...
-
getUserName
Method getUserName() brings back the User Name (again, we saved it).- Returns:
- the user name
- Throws:
SQLException
- just in case...
-
getFastpathAPI
Description copied from interface:PGConnection
This returns the Fastpath API for the current connection.- Specified by:
getFastpathAPI
in interfacePGConnection
- Returns:
- Fastpath API for the current connection
- Throws:
SQLException
- if something wrong happens
-
getLargeObjectAPI
Description copied from interface:PGConnection
This returns the LargeObject API for the current connection.- Specified by:
getLargeObjectAPI
in interfacePGConnection
- Returns:
- LargeObject API for the current connection
- Throws:
SQLException
- if something wrong happens
-
getObject
public Object getObject(String type, @Nullable String value, byte @Nullable [] byteValue) throws SQLException Description copied from interface:BaseConnection
Construct 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
PGobject
instance is returned.value or byteValue must be non-null
- Specified by:
getObject
in interfaceBaseConnection
- 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:
SQLException
- if something goes wrong
-
createTypeInfo
-
getTypeInfo
- Specified by:
getTypeInfo
in interfaceBaseConnection
-
addDataType
Description copied from interface:PGConnection
This allows client code to add a handler for one of org.postgresql's more unique data types. It is approximately equivalent toaddDataType(type, Class.forName(name))
.- Specified by:
addDataType
in interfacePGConnection
- Parameters:
type
- JDBC type namename
- class name
-
addDataType
Description copied from interface:PGConnection
This allows client code to add a handler for one of org.postgresql's more unique data types.
NOTE: This is not part of JDBC, but an extension.
The best way to use this is as follows:
... ((org.postgresql.PGConnection)myconn).addDataType("mytype", my.class.name.class); ...
where myconn is an open Connection to org.postgresql.
The handling class must extend org.postgresql.util.PGobject
- Specified by:
addDataType
in interfacePGConnection
- Parameters:
type
- the PostgreSQL type to registerklass
- the class implementing the Java representation of the type; this class must implementPGobject
).- Throws:
SQLException
- ifklass
does not implementPGobject
).- See Also:
-
close
Note: even thoughStatement
is automatically closed when it is garbage collected, it is better to close it explicitly to lower resource consumption. The spec says that calling close on a closed connection is a no-op.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
-
nativeSQL
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
getWarnings
- Specified by:
getWarnings
in interfaceConnection
- Throws:
SQLException
-
clearWarnings
- Specified by:
clearWarnings
in interfaceConnection
- Throws:
SQLException
-
setReadOnly
- Specified by:
setReadOnly
in interfaceConnection
- Throws:
SQLException
-
isReadOnly
- Specified by:
isReadOnly
in interfaceConnection
- Throws:
SQLException
-
hintReadOnly
public boolean hintReadOnly()Description copied from interface:BaseConnection
Indicates if statements to backend should be hinted as read only.- Specified by:
hintReadOnly
in interfaceBaseConnection
- Returns:
- Indication if hints to backend (such as when transaction begins) should be read only.
- See Also:
-
setAutoCommit
- Specified by:
setAutoCommit
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
- Specified by:
getAutoCommit
in interfaceConnection
- Throws:
SQLException
-
commit
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
-
checkClosed
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
getTransactionState
Description copied from interface:BaseConnection
Get the current transaction state of this connection.- Specified by:
getTransactionState
in interfaceBaseConnection
- Returns:
- current transaction state of this connection
-
getTransactionIsolation
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
- Specified by:
setTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
getIsolationLevelName
-
setCatalog
- Specified by:
setCatalog
in interfaceConnection
- Throws:
SQLException
-
getCatalog
- Specified by:
getCatalog
in interfaceConnection
- Throws:
SQLException
-
getHideUnprivilegedObjects
public boolean getHideUnprivilegedObjects() -
getDBVersionNumber
Get server version number.- Returns:
- server version number
-
getServerMajorVersion
public int getServerMajorVersion()Get server major version.- Returns:
- server major version
-
getServerMinorVersion
public int getServerMinorVersion()Get server minor version.- Returns:
- server minor version
-
haveMinimumServerVersion
public boolean haveMinimumServerVersion(int ver) Description copied from interface:BaseConnection
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.
- Specified by:
haveMinimumServerVersion
in interfaceBaseConnection
- Parameters:
ver
- the server version to check, of the form xxyyzz eg 90401- Returns:
- true if the server version is at least "ver".
-
haveMinimumServerVersion
Description copied from interface:BaseConnection
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.
- Specified by:
haveMinimumServerVersion
in interfaceBaseConnection
- Parameters:
ver
- the server version to check- Returns:
- true if the server version is at least "ver".
-
getEncoding
- Specified by:
getEncoding
in interfaceBaseConnection
-
encodeString
Description copied from interface:BaseConnection
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).- Specified by:
encodeString
in interfaceBaseConnection
- Parameters:
str
- the string to encode- Returns:
- an encoded representation of the string
- Throws:
SQLException
- if something goes wrong.
-
escapeString
Description copied from interface:BaseConnection
Escapes a string for use as string-literal within an SQL command. The method chooses the applicable escaping rules based on the value ofBaseConnection.getStandardConformingStrings()
.- Specified by:
escapeString
in interfaceBaseConnection
- Parameters:
str
- a string value- Returns:
- the escaped representation of the string
- Throws:
SQLException
- if the string contains a\0
character
-
getStandardConformingStrings
public boolean getStandardConformingStrings()Description copied from interface:BaseConnection
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_strings
server variable.- Specified by:
getStandardConformingStrings
in interfaceBaseConnection
- Returns:
- true if the server treats string literals according to the SQL standard
- See Also:
-
isClosed
- Specified by:
isClosed
in interfaceConnection
- Throws:
SQLException
-
cancelQuery
Description copied from interface:BaseConnection
Cancel the current query executing on this connection.- Specified by:
cancelQuery
in interfaceBaseConnection
- Specified by:
cancelQuery
in interfacePGConnection
- Throws:
SQLException
- if something goes wrong.
-
getNotifications
Description copied from interface:PGConnection
This method returns any notifications that have been received since the last call to this method. Returns null if there have been no notifications.- Specified by:
getNotifications
in interfacePGConnection
- Returns:
- notifications that have been received
- Throws:
SQLException
- if something wrong happens
-
getNotifications
Description copied from interface:PGConnection
This method returns any notifications that have been received since the last call to this method. Returns null if there have been no notifications. A timeout can be specified so the driver waits for notifications.- Specified by:
getNotifications
in interfacePGConnection
- Parameters:
timeoutMillis
- when 0, blocks forever. when > 0, blocks up to the specified number of millis or until at least one notification has been received. If more than one notification is about to be received, these will be returned in one batch.- Returns:
- notifications that have been received
- Throws:
SQLException
- if something wrong happens
-
getPrepareThreshold
public int getPrepareThreshold()Description copied from interface:PGConnection
Get the default server-side prepare reuse threshold for statements created from this connection.- Specified by:
getPrepareThreshold
in interfacePGConnection
- Returns:
- the current threshold
-
setDefaultFetchSize
Description copied from interface:PGConnection
Set the default fetch size for statements created from this connection.- Specified by:
setDefaultFetchSize
in interfacePGConnection
- Parameters:
fetchSize
- new default fetch size- Throws:
SQLException
- if specified negativefetchSize
parameter- See Also:
-
getDefaultFetchSize
public int getDefaultFetchSize()Description copied from interface:PGConnection
Get the default fetch size for statements created from this connection.- Specified by:
getDefaultFetchSize
in interfacePGConnection
- Returns:
- current state for default fetch size
- See Also:
-
setPrepareThreshold
public void setPrepareThreshold(int newThreshold) Description copied from interface:PGConnection
Set the default statement reuse threshold before enabling server-side prepare. SeePGStatement.setPrepareThreshold(int)
for details.- Specified by:
setPrepareThreshold
in interfacePGConnection
- Parameters:
newThreshold
- the new threshold
-
getForceBinary
public boolean getForceBinary() -
setForceBinary
public void setForceBinary(boolean newValue) -
setTypeMapImpl
- Throws:
SQLException
-
getLogger
- Specified by:
getLogger
in interfaceBaseConnection
-
getProtocolVersion
public int getProtocolVersion() -
getStringVarcharFlag
public boolean getStringVarcharFlag()- Specified by:
getStringVarcharFlag
in interfaceBaseConnection
-
getCopyAPI
Description copied from interface:PGConnection
This returns the COPY API for the current connection.- Specified by:
getCopyAPI
in interfacePGConnection
- Returns:
- COPY API for the current connection
- Throws:
SQLException
- if something wrong happens
-
binaryTransferSend
public boolean binaryTransferSend(int oid) Description copied from interface:BaseConnection
Returns true if value for the given oid should be sent using binary transfer. False if value should be sent using text transfer.- Specified by:
binaryTransferSend
in interfaceBaseConnection
- Parameters:
oid
- The oid to check.- Returns:
- True for binary transfer, false for text transfer.
-
getBackendPID
public int getBackendPID()Description copied from interface:PGConnection
Return the process ID (PID) of the backend server process handling this connection.- Specified by:
getBackendPID
in interfacePGConnection
- Returns:
- PID of backend server process.
-
isColumnSanitiserDisabled
public boolean isColumnSanitiserDisabled()Description copied from interface:BaseConnection
Return whether to disable column name sanitation.- Specified by:
isColumnSanitiserDisabled
in interfaceBaseConnection
- Returns:
- true column sanitizer is disabled
-
setDisableColumnSanitiser
public void setDisableColumnSanitiser(boolean disableColumnSanitiser) -
getPreferQueryMode
Description copied from interface:PGConnection
Returns the query mode for this connection.
When running in simple query mode, certain features are not available: callable statements, partial result set fetch, bytea type, etc.
The list of supported features is subject to change.
- Specified by:
getPreferQueryMode
in interfacePGConnection
- Returns:
- the preferred query mode
- See Also:
-
getAutosave
Description copied from interface:PGConnection
Connection configuration regarding automatic per-query savepoints.- Specified by:
getAutosave
in interfacePGConnection
- Returns:
- connection configuration regarding automatic per-query savepoints
- See Also:
-
setAutosave
Description copied from interface:PGConnection
Configures if connection should use automatic savepoints.- Specified by:
setAutosave
in interfacePGConnection
- Parameters:
autoSave
- connection configuration regarding automatic per-query savepoints- See Also:
-
abort
protected void abort() -
addTimerTask
Description copied from interface:BaseConnection
Schedule a TimerTask for later execution. The task will be scheduled with the shared Timer for this connection.- Specified by:
addTimerTask
in interfaceBaseConnection
- Parameters:
timerTask
- timer task to schedulemilliSeconds
- delay in milliseconds
-
purgeTimerTasks
public void purgeTimerTasks()Description copied from interface:BaseConnection
Invoke purge() on the underlying shared Timer so that internal resources will be released.- Specified by:
purgeTimerTasks
in interfaceBaseConnection
-
escapeIdentifier
Description copied from interface:PGConnection
Return the given string suitably quoted to be used as an identifier in an SQL statement string. Quotes are added only if necessary (i.e., if the string contains non-identifier characters or would be case-folded). Embedded quotes are properly doubled.- Specified by:
escapeIdentifier
in interfacePGConnection
- Parameters:
identifier
- input identifier- Returns:
- the escaped identifier
- Throws:
SQLException
- if something goes wrong
-
escapeLiteral
Description copied from interface:PGConnection
Return the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input.- Specified by:
escapeLiteral
in interfacePGConnection
- Parameters:
literal
- input literal- Returns:
- the quoted literal
- Throws:
SQLException
- if something goes wrong
-
getFieldMetadataCache
Description copied from interface:BaseConnection
Return metadata cache for given connection.- Specified by:
getFieldMetadataCache
in interfaceBaseConnection
- Returns:
- metadata cache
-
getReplicationAPI
- Specified by:
getReplicationAPI
in interfacePGConnection
- Returns:
- replication API for the current connection
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
getMetaData
- Specified by:
getMetaData
in interfaceConnection
- Throws:
SQLException
-
setTypeMap
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
makeArray
- Throws:
SQLException
-
makeBlob
- Throws:
SQLException
-
makeClob
- Throws:
SQLException
-
makeSQLXML
- Throws:
SQLException
-
createClob
- Specified by:
createClob
in interfaceConnection
- Throws:
SQLException
-
createBlob
- Specified by:
createBlob
in interfaceConnection
- Throws:
SQLException
-
createNClob
- Specified by:
createNClob
in interfaceConnection
- Throws:
SQLException
-
createSQLXML
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
createStruct
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
createArrayOf
Description copied from interface:PGConnection
Creates anArray
wrapping elements. This is similar toConnection.createArrayOf(String, Object[])
, but also provides support for primitive arrays.- Specified by:
createArrayOf
in interfacePGConnection
- Parameters:
typeName
- The SQL name of the type to map the elements to. Must not benull
.elements
- The array of objects to map. Anull
value will result in anArray
representingnull
.- Returns:
- An
Array
wrapping elements. - Throws:
SQLException
- If for some reason the array cannot be created.- See Also:
-
createArrayOf
public Array createArrayOf(String typeName, @Nullable Object @Nullable [] elements) throws SQLException - Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
isValid
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
setClientInfo
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
getClientInfo
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
createQueryObject
- Throws:
SQLException
-
getLogServerErrorDetail
public boolean getLogServerErrorDetail()Description copied from interface:BaseConnection
Indicates if error details from server used in included in logging and exceptions.- Specified by:
getLogServerErrorDetail
in interfaceBaseConnection
- Returns:
- true if should be included and passed on to other exceptions
-
isWrapperFor
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
getSchema
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
setSchema
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
abort
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
- Specified by:
getNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
setHoldability
- Specified by:
setHoldability
in interfaceConnection
- Throws:
SQLException
-
getHoldability
- Specified by:
getHoldability
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
rollback
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
createStatement
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException - Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int @Nullable [] columnIndexes) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String @Nullable [] columnNames) throws SQLException - Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
getParameterStatuses
Description copied from interface:PGConnection
Returns the current values of all parameters reported by the server.
PostgreSQL reports values for a subset of parameters (GUCs) to the client at connect-time, then sends update messages whenever the values change during a session. PgJDBC records the latest values and exposes it to client applications via
getParameterStatuses()
.PgJDBC exposes individual accessors for some of these parameters as listed below. They are more backwards-compatible and should be preferred where possible.
Not all parameters are reported, only those marked
GUC_REPORT
in the source code. Thepg_settings
view does not expose information about which parameters are reportable. PgJDBC's map will only contain the parameters the server reports values for, so you cannot use this method as a substitute for running aSHOW paramname;
orSELECT current_setting('paramname');
query for arbitrary parameters.Parameter names are case-insensitive and case-preserving in this map, like in PostgreSQL itself. So
DateStyle
anddatestyle
are the same key.As of PostgreSQL 11 the reportable parameter list, and related PgJDBC interfaces or assessors, are:
-
application_name
-Connection.getClientInfo()
,Connection.setClientInfo(java.util.Properties)
andApplicationName
connection property. -
client_encoding
- PgJDBC always sets this toUTF8
. SeeallowEncodingChanges
connection property. DateStyle
- PgJDBC requires this to always be set toISO
standard_conforming_strings
- indirectly viaPGConnection.escapeLiteral(String)
-
TimeZone
- set from JDK timezone seeTimeZone.getDefault()
andTimeZone.setDefault(TimeZone)
integer_datetimes
IntervalStyle
server_encoding
server_version
is_superuser
session_authorization
Note that some PgJDBC operations will change server parameters automatically.
- Specified by:
getParameterStatuses
in interfacePGConnection
- Returns:
- unmodifiable map of case-insensitive parameter names to parameter values
-
-
getParameterStatus
Description copied from interface:PGConnection
Shorthand for getParameterStatuses().get(...) .- Specified by:
getParameterStatus
in interfacePGConnection
- Parameters:
parameterName
- case-insensitive parameter name- Returns:
- parameter value if defined, or null if no parameter known
- See Also:
-
getAdaptiveFetch
public boolean getAdaptiveFetch()Description copied from interface:PGConnection
Get state of adaptive fetch for connection.- Specified by:
getAdaptiveFetch
in interfacePGConnection
- Returns:
- state of adaptive fetch (turned on or off)
-
setAdaptiveFetch
public void setAdaptiveFetch(boolean adaptiveFetch) Description copied from interface:PGConnection
Turn on/off adaptive fetch for connection. Existing statements and resultSets won't be affected by change here.- Specified by:
setAdaptiveFetch
in interfacePGConnection
- Parameters:
adaptiveFetch
- desired state of adaptive fetch.
-
getXmlFactoryFactory
Description copied from interface:BaseConnection
Retrieve the factory to instantiate XML processing factories.- Specified by:
getXmlFactoryFactory
in interfaceBaseConnection
- Returns:
- The factory to use to instantiate XML processing factories
- Throws:
SQLException
- if the class cannot be found or instantiated.
-