Class OraclePooledConnection
- java.lang.Object
-
- oracle.jdbc.pool.OraclePooledConnection
-
- All Implemented Interfaces:
java.io.Serializable,javax.sql.PooledConnection,OraclePooledConnection,oracle.jdbc.diagnostics.Diagnosable,oracle.jdbc.diagnostics.PropertyChangeListener,oracle.jdbc.internal.Monitor
- Direct Known Subclasses:
OracleXAConnection
public class OraclePooledConnection extends java.lang.Object implements OraclePooledConnection, java.io.Serializable, oracle.jdbc.internal.Monitor, oracle.jdbc.diagnostics.Diagnosable
An OraclePooledConnection object is a connection object that provides hooks for connection pool management. A PooledConnection object represents a physical connection to a data source. It implements javax.sql.PooledConnection
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanautoCommitstatic java.lang.Stringclose_callback_stringintcloseOptionstatic java.lang.Stringconnect_auto_commit_stringstatic java.lang.Stringconnection_properties_stringstatic java.lang.Stringevent_listener_stringstatic java.lang.Stringexplicit_caching_enabledstatic java.lang.StringExplicitStatementCachingEnabledstatic java.lang.Stringimplicit_caching_enabledstatic java.lang.StringImplicitStatementCachingEnabledstatic java.lang.StringisClearMetaDataprotected oracle.jdbc.internal.OracleConnectionlogicalHandlestatic java.lang.StringLoginTimeoutstatic java.lang.StringNO_IMPLICIT_BEGIN_REQUEST_PROPERTYstatic java.lang.Stringobject_type_mapprotected oracle.jdbc.driver.OracleDriveroracleDriverprotected oracle.jdbc.internal.OracleConnectionphysicalConnstatic java.lang.Stringpool_auto_commit_stringstatic java.lang.Stringprivate_dataprotected oracle.jdbc.internal.OracleConnectionreplayConnstatic java.lang.Stringsql_exception_stringstatic java.lang.Stringstatement_cache_sizestatic java.lang.Stringtransaction_isolationstatic java.lang.Stringurl_string
-
Constructor Summary
Constructors Constructor Description OraclePooledConnection()OraclePooledConnection(java.lang.String url)Creates a PooledConnection.OraclePooledConnection(java.lang.String url, java.lang.String user, java.lang.String passwd)Creates a PooledConnection.OraclePooledConnection(java.sql.Connection pc)Create a Pooled Connection.OraclePooledConnection(java.sql.Connection pc, boolean ac)Create a Pooled Connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddConnectionEventListener(javax.sql.ConnectionEventListener cel)Add an event listener.voidaddStatementEventListener(javax.sql.StatementEventListener listener)voidclose()Close the physical connection.java.sql.CallableStatementgetCallWithKey(java.lang.String key)getCallWithKey Searches the explicit cache for a match on key.java.sql.ConnectiongetConnection()Create an object handle for this physical connection.protected oracle.jdbc.internal.OracleConnectiongetConnectionDuringExceptionHandling()oracle.jdbc.diagnostics.DiagnosablegetDiagnosable()booleangetExplicitCachingEnabled()getExplicitCachingEnabled Returns true if the explicit cache is currently enabled, false otherwise.booleangetImplicitCachingEnabled()getImplicitCachingEnabled Returns true if the implicit cache is currently enabled, false otherwise.longgetLastAccessedTime()Deprecated.java.sql.ConnectiongetLogicalHandle()Return the logical handle to the caller.oracle.jdbc.internal.Monitor.CloseableLockgetMonitorLock()java.sql.ConnectiongetPhysicalHandle()intgetStatementCacheSize()getStatementCacheSize Returns the current size of the application cache.java.sql.PreparedStatementgetStatementWithKey(java.lang.String key)getStatementWithKey Searches the explicit cache for a match on key.intgetStmtCacheSize()Deprecated.javax.transaction.xa.XAResourcegetXAResource()Return an XA resource to the caller.booleanisStatementCacheInitialized()voidpurgeExplicitCache()purgeExplicitCache Removes all existing statements from the explicit cache, after which it will be empty.voidpurgeImplicitCache()purgeImplicitCache Removes all existing statements from the implicit cache, after which it will be empty.voidregisterImplicitCacheConnectionEventListener(javax.sql.ConnectionEventListener cel)Deprecated.voidremoveConnectionEventListener(javax.sql.ConnectionEventListener cel)Remove an event listener.voidremoveStatementEventListener(javax.sql.StatementEventListener listener)voidsetConnection(oracle.jdbc.internal.OracleConnection rconn)voidsetExplicitCachingEnabled(boolean cache)setExplicitCachingEnabled Enables or disables the explicit cache.voidsetImplicitCachingEnabled(boolean cache)setImplicitCachingEnabled Enables or disables the implicit cache.voidsetLastAccessedTime(long lastAccessedTime)Deprecated.voidsetProperties(java.util.Hashtable prop)voidsetShardingKey(OracleShardingKey shardingKey, OracleShardingKey superShardingKey)Sets the sharding key and the super sharding key on this connection.booleansetShardingKeyIfValid(OracleShardingKey shardingKey, OracleShardingKey superShardingKey, int timeout)Checks the validity of the connection and also checks if the sharding keys passed to this method are valid for the connection.If the sharding keys are valid, it will be set on the connection's session.voidsetStatementCacheSize(int size)setStatementCacheSize Specifies the size of the size of the application cache (which will be used by both implicit and explicit caching).voidsetStmtCacheSize(int size)Deprecated.voidsetStmtCacheSize(int size, boolean clearMetaData)Deprecated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface oracle.jdbc.diagnostics.Diagnosable
begin, beginCurrentSql, debug, debug, debug, debug, debug, debug, debug, debug, debug, debug, debugp, end, endCurrentSql, format, isDebugEnabled, isDiagnoseFirstFailureEnabled, isLoggable, isSensitiveEnabled, onClose, propertyChange, resumeLogging, secure, suspendLogging, trace, tracep
-
-
-
-
Field Detail
-
url_string
public static final java.lang.String url_string
- See Also:
- Constant Field Values
-
pool_auto_commit_string
public static final java.lang.String pool_auto_commit_string
- See Also:
- Constant Field Values
-
object_type_map
public static final java.lang.String object_type_map
- See Also:
- Constant Field Values
-
transaction_isolation
public static final java.lang.String transaction_isolation
- See Also:
- Constant Field Values
-
statement_cache_size
public static final java.lang.String statement_cache_size
- See Also:
- Constant Field Values
-
isClearMetaData
public static final java.lang.String isClearMetaData
- See Also:
- Constant Field Values
-
ImplicitStatementCachingEnabled
public static final java.lang.String ImplicitStatementCachingEnabled
- See Also:
- Constant Field Values
-
ExplicitStatementCachingEnabled
public static final java.lang.String ExplicitStatementCachingEnabled
- See Also:
- Constant Field Values
-
LoginTimeout
public static final java.lang.String LoginTimeout
- See Also:
- Constant Field Values
-
connect_auto_commit_string
public static final java.lang.String connect_auto_commit_string
- See Also:
- Constant Field Values
-
implicit_caching_enabled
public static final java.lang.String implicit_caching_enabled
- See Also:
- Constant Field Values
-
explicit_caching_enabled
public static final java.lang.String explicit_caching_enabled
- See Also:
- Constant Field Values
-
connection_properties_string
public static final java.lang.String connection_properties_string
- See Also:
- Constant Field Values
-
event_listener_string
public static final java.lang.String event_listener_string
- See Also:
- Constant Field Values
-
sql_exception_string
public static final java.lang.String sql_exception_string
- See Also:
- Constant Field Values
-
close_callback_string
public static final java.lang.String close_callback_string
- See Also:
- Constant Field Values
-
private_data
public static final java.lang.String private_data
- See Also:
- Constant Field Values
-
autoCommit
protected boolean autoCommit
-
logicalHandle
protected transient oracle.jdbc.internal.OracleConnection logicalHandle
-
physicalConn
protected transient oracle.jdbc.internal.OracleConnection physicalConn
-
replayConn
protected transient oracle.jdbc.internal.OracleConnection replayConn
-
closeOption
public int closeOption
-
oracleDriver
protected transient oracle.jdbc.driver.OracleDriver oracleDriver
-
NO_IMPLICIT_BEGIN_REQUEST_PROPERTY
public static final java.lang.String NO_IMPLICIT_BEGIN_REQUEST_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OraclePooledConnection
public OraclePooledConnection()
-
OraclePooledConnection
public OraclePooledConnection(java.lang.String url) throws java.sql.SQLExceptionCreates a PooledConnection.
- Parameters:
url- URL of the physical connection.- Throws:
java.sql.SQLException
-
OraclePooledConnection
public OraclePooledConnection(java.lang.String url, java.lang.String user, java.lang.String passwd) throws java.sql.SQLExceptionCreates a PooledConnection.
- Parameters:
url- URL of the physical connection.user- Usernamepasswd- Password- Throws:
java.sql.SQLException
-
OraclePooledConnection
public OraclePooledConnection(java.sql.Connection pc)
Create a Pooled Connection.
- Parameters:
pc- The corresponding physical connection.
-
OraclePooledConnection
public OraclePooledConnection(java.sql.Connection pc, boolean ac)Create a Pooled Connection.
- Parameters:
pc- The corresponding physical connectionac- autoCommit value
-
-
Method Detail
-
addConnectionEventListener
public void addConnectionEventListener(javax.sql.ConnectionEventListener cel)
Add an event listener.
- Specified by:
addConnectionEventListenerin interfacejavax.sql.PooledConnection- Parameters:
cel- The listener to be added
-
close
public void close() throws java.sql.SQLExceptionClose the physical connection.
- Specified by:
closein interfacejavax.sql.PooledConnection- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionCreate an object handle for this physical connection. The object returned is a temporary handle used by application code to refer to a physical connection that is being pooled.
- Specified by:
getConnectionin interfacejavax.sql.PooledConnection- Returns:
- a Connection object
- Throws:
java.sql.SQLException- if a database-access error occurs.
-
getLogicalHandle
public java.sql.Connection getLogicalHandle() throws java.sql.SQLExceptionReturn the logical handle to the caller. This logical handle refers to the physical connection that is pooled.
- Specified by:
getLogicalHandlein interfaceOraclePooledConnection- Returns:
- a Connection object
- Throws:
java.sql.SQLException
-
getPhysicalHandle
public java.sql.Connection getPhysicalHandle() throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setLastAccessedTime
@Deprecated public void setLastAccessedTime(long lastAccessedTime) throws java.sql.SQLExceptionDeprecated.- Specified by:
setLastAccessedTimein interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
getLastAccessedTime
@Deprecated public long getLastAccessedTime() throws java.sql.SQLExceptionDeprecated.- Specified by:
getLastAccessedTimein interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
registerImplicitCacheConnectionEventListener
@Deprecated public void registerImplicitCacheConnectionEventListener(javax.sql.ConnectionEventListener cel)
Deprecated.- Specified by:
registerImplicitCacheConnectionEventListenerin interfaceOraclePooledConnection
-
removeConnectionEventListener
public void removeConnectionEventListener(javax.sql.ConnectionEventListener cel)
Remove an event listener.
- Specified by:
removeConnectionEventListenerin interfacejavax.sql.PooledConnection- Parameters:
cel- The listener to be removed.
-
setStmtCacheSize
public void setStmtCacheSize(int size) throws java.sql.SQLExceptionDeprecated.Set the statement cache size. Default is 0. You cannot call this for logicalhandles obtained from PooledConnections.If more than <it> size </it> cursors are already cached than they will be closed. By default, the metadata of the cursor will be saved. Only data and the state will be cleared. You need to call this first to enable either type of Statement caching. When both types of Statement caching are enabled, the <it> size </size> is the total number of cursors cached for both the schemes together.
- Parameters:
size- Size of the Cache- Throws:
java.sql.SQLException
-
setStmtCacheSize
public void setStmtCacheSize(int size, boolean clearMetaData) throws java.sql.SQLExceptionDeprecated.Set the statement cache size. Default is 0. You cannot call this for logicalhandles obtained from PooledConnections.If more than <it> size </it> cursors are already cached than they will be closed. By default, the metadata of the cursor will be saved. But if clearMetaData is set to true, even that will be cleared. You need to call this first to enable either type of Statement caching. When both types of Statement caching are enabled, the <it> size </size> is the total number of cursors cached for both the schemes together.
- Parameters:
size- Size of the CacheclearMetaData- Whether the state has to be cleared or not- Throws:
java.sql.SQLException
-
getStmtCacheSize
public int getStmtCacheSize()
Deprecated.Return the size of Statement Cache.- Returns:
- int Size of Statement Cache. If not set, the default 0 is returned.
-
setStatementCacheSize
public void setStatementCacheSize(int size) throws java.sql.SQLExceptionsetStatementCacheSize Specifies the size of the size of the application cache (which will be used by both implicit and explicit caching).- Specified by:
setStatementCacheSizein interfaceOraclePooledConnection- Parameters:
size- Requested size of the cache. If the existing cache size is less than size, statements will be purged to reduce the size.- Throws:
java.sql.SQLException- if size < 0, or if called on a logical connection.
-
getStatementCacheSize
public int getStatementCacheSize() throws java.sql.SQLExceptiongetStatementCacheSize Returns the current size of the application cache. This is valid on both physical and logical connections.- Specified by:
getStatementCacheSizein interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
setImplicitCachingEnabled
public void setImplicitCachingEnabled(boolean cache) throws java.sql.SQLExceptionsetImplicitCachingEnabled Enables or disables the implicit cache. Note that this is independent of the cache size, set with setStatementCacheSize().- Specified by:
setImplicitCachingEnabledin interfaceOraclePooledConnection- Parameters:
cache- If true, then implicit caching will be enabled. If false, then any existing statements will be purged and the implicit cache will be disabled.- Throws:
java.sql.SQLException- if called on a logical connection.
-
getImplicitCachingEnabled
public boolean getImplicitCachingEnabled() throws java.sql.SQLExceptiongetImplicitCachingEnabled Returns true if the implicit cache is currently enabled, false otherwise. This method is valid on both logical and physical connections.- Specified by:
getImplicitCachingEnabledin interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
setExplicitCachingEnabled
public void setExplicitCachingEnabled(boolean cache) throws java.sql.SQLExceptionsetExplicitCachingEnabled Enables or disables the explicit cache. Note that this is independent of the cache size, set with setStatementCacheSize().- Specified by:
setExplicitCachingEnabledin interfaceOraclePooledConnection- Parameters:
cache- If true, then explicit caching will be enabled. If false, then any existing statements will be purged and the explicit cache will be disabled.- Throws:
java.sql.SQLException- if called on a logical connection.
-
getExplicitCachingEnabled
public boolean getExplicitCachingEnabled() throws java.sql.SQLExceptiongetExplicitCachingEnabled Returns true if the explicit cache is currently enabled, false otherwise. This method is valid on both logical and physical connections.- Specified by:
getExplicitCachingEnabledin interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
purgeImplicitCache
public void purgeImplicitCache() throws java.sql.SQLExceptionpurgeImplicitCache Removes all existing statements from the implicit cache, after which it will be empty. This method does not affect the size of the application cache, nor the enabled/disabled status.- Specified by:
purgeImplicitCachein interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
purgeExplicitCache
public void purgeExplicitCache() throws java.sql.SQLExceptionpurgeExplicitCache Removes all existing statements from the explicit cache, after which it will be empty. This method does not affect the size of the application cache, nor the enabled/disabled status.- Specified by:
purgeExplicitCachein interfaceOraclePooledConnection- Throws:
java.sql.SQLException
-
getStatementWithKey
public java.sql.PreparedStatement getStatementWithKey(java.lang.String key) throws java.sql.SQLExceptiongetStatementWithKey Searches the explicit cache for a match on key. If found, the statement is returned, with the parameter and define metadata identical to the last usage. If a CallableStatement is found (instead of a PreparedStatement) ORA-17125 is raised. If no match is found, or if explicit caching is not enabled, null is returned.- Specified by:
getStatementWithKeyin interfaceOraclePooledConnection- Parameters:
key- Specified key to search for- Throws:
java.sql.SQLException
-
getCallWithKey
public java.sql.CallableStatement getCallWithKey(java.lang.String key) throws java.sql.SQLExceptiongetCallWithKey Searches the explicit cache for a match on key. If found, the statement is returned, with the parameter and define metadata identical to the last usage. If a PreparedStatement is found (instead of a CallableStatement) ORA-17125 is raised. If no match is found, or if explicit caching is not enabled, null is returned.- Specified by:
getCallWithKeyin interfaceOraclePooledConnection- Parameters:
key- Specified key to search for- Throws:
java.sql.SQLException
-
isStatementCacheInitialized
public boolean isStatementCacheInitialized()
-
setProperties
public final void setProperties(java.util.Hashtable prop)
-
getXAResource
public javax.transaction.xa.XAResource getXAResource() throws java.sql.SQLExceptionReturn an XA resource to the caller. This is just a placeholder. Only the one on XAConnection is meaningful.- Specified by:
getXAResourcein interfaceOraclePooledConnection- Returns:
- the XAResource (null if error occurs)
- Throws:
java.sql.SQLException- if a database error occurs
-
addStatementEventListener
public void addStatementEventListener(javax.sql.StatementEventListener listener)
- Specified by:
addStatementEventListenerin interfacejavax.sql.PooledConnection
-
removeStatementEventListener
public void removeStatementEventListener(javax.sql.StatementEventListener listener)
- Specified by:
removeStatementEventListenerin interfacejavax.sql.PooledConnection
-
setConnection
public void setConnection(oracle.jdbc.internal.OracleConnection rconn) throws java.sql.SQLException- Throws:
java.sql.SQLException
-
setShardingKeyIfValid
public boolean setShardingKeyIfValid(OracleShardingKey shardingKey, OracleShardingKey superShardingKey, int timeout) throws java.sql.SQLException
Checks the validity of the connection and also checks if the sharding keys passed to this method are valid for the connection.If the sharding keys are valid, it will be set on the connection's session.- Specified by:
setShardingKeyIfValidin interfaceOraclePooledConnection- Parameters:
shardingKey- Sharding key to be validated against this connectionsuperShardingKey- Super Sharding key to be validated against this connectiontimeout- Time in seconds before which the validation process is expected to be complete, else the validation process is aborted. The value of the timeout must be set to zero to disable the timeout during the validation.- Returns:
- true if the connection is valid and the shard keys are valid to be set on this connection.
- Throws:
java.sql.SQLException- if there is any exception while performing this validation or if timeout value is less than 0.
-
setShardingKey
public void setShardingKey(OracleShardingKey shardingKey, OracleShardingKey superShardingKey) throws java.sql.SQLException
Sets the sharding key and the super sharding key on this connection.- Specified by:
setShardingKeyin interfaceOraclePooledConnection- Parameters:
shardingKey- sharding key to be set on this connectionsuperShardingKey- Super Sharding key to be set on this connection- Throws:
java.sql.SQLException- if there is an exception while setting the sharding keys on this connection.
-
getConnectionDuringExceptionHandling
protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()
-
getMonitorLock
public final oracle.jdbc.internal.Monitor.CloseableLock getMonitorLock()
- Specified by:
getMonitorLockin interfaceoracle.jdbc.internal.Monitor
-
getDiagnosable
public oracle.jdbc.diagnostics.Diagnosable getDiagnosable()
- Specified by:
getDiagnosablein interfaceoracle.jdbc.diagnostics.Diagnosable
-
-