Skip navigation links

Oracle®Database JDBC Java API Reference
12c Release 1 (12.1.0.2)
E56669-01


oracle.jdbc.pool
Class OraclePooledConnection

java.lang.Object
  extended by oracle.jdbc.pool.OraclePooledConnection

All Implemented Interfaces:
Serializable, PooledConnection
Direct Known Subclasses:
OracleXAConnection

public class OraclePooledConnection
extends Object
implements PooledConnection, Serializable

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
protected  boolean autoCommit
           
 Properties cachedConnectionAttributes
           
static String close_callback_string
           
 int closeOption
           
static String connect_auto_commit_string
           
static String connection_properties_string
           
protected  boolean connectionMarkedDown
           
protected  String dataSourceDbUniqNameKey
           
protected  String dataSourceHostNameKey
           
protected  String dataSourceInstanceNameKey
           
static String event_listener_string
           
static String explicit_caching_enabled
           
static String ExplicitStatementCachingEnabled
           
static String implicit_caching_enabled
           
static String ImplicitStatementCachingEnabled
           
static String isClearMetaData
           
protected  oracle.jdbc.internal.OracleConnection logicalHandle
           
static String LoginTimeout
           
protected  boolean needToAbort
           
static String object_type_map
           
protected  oracle.jdbc.driver.OracleDriver oracleDriver
           
protected  oracle.jdbc.internal.OracleConnection physicalConn
           
static String pool_auto_commit_string
           
static String private_data
           
static String sql_exception_string
           
static String statement_cache_size
           
static boolean TRACE
           
static String transaction_isolation
           
 Properties unMatchedCachedConnAttr
           
static String url_string
           

 

Constructor Summary
OraclePooledConnection()
           
OraclePooledConnection(Connection pc)
           Create a Pooled Connection.
OraclePooledConnection(Connection pc, boolean ac)
           Create a Pooled Connection.
OraclePooledConnection(String url)
           Creates a PooledConnection.
OraclePooledConnection(String url, String user, String passwd)
           Creates a PooledConnection.

 

Method Summary
 void addConnectionEventListener(ConnectionEventListener cel)
           Add an event listener.
 void addStatementEventListener(StatementEventListener listener)
           
 void close()
          Close the physical connection.
 CallableStatement getCallWithKey(String key)
          getCallWithKey Searches the explicit cache for a match on key.
 Connection getConnection()
          Create an object handle for this physical connection.
protected  oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()
           
 boolean getExplicitCachingEnabled()
          getExplicitCachingEnabled Returns true if the explicit cache is currently enabled, false otherwise.
 boolean getImplicitCachingEnabled()
          getImplicitCachingEnabled Returns true if the implicit cache is currently enabled, false otherwise.
 long getLastAccessedTime()
          Get the last accessed time on the PooledConnection.
 Connection getLogicalHandle()
          Return the logical handle to the caller.
 Connection getPhysicalHandle()
           
 int getStatementCacheSize()
          getStatementCacheSize Returns the current size of the application cache.
 PreparedStatement getStatementWithKey(String key)
          getStatementWithKey Searches the explicit cache for a match on key.
 int getStmtCacheSize()
          Deprecated.  
 XAResource getXAResource()
          Return an XA resource to the caller.
 boolean isStatementCacheInitialized()
           
 void purgeExplicitCache()
          purgeExplicitCache Removes all existing statements from the explicit cache, after which it will be empty.
 void purgeImplicitCache()
          purgeImplicitCache Removes all existing statements from the implicit cache, after which it will be empty.
 void registerImplicitCacheConnectionEventListener(ConnectionEventListener cel)
           Register an event listener for the implicit connection cache.
 void removeConnectionEventListener(ConnectionEventListener cel)
           Remove an event listener.
 void removeStatementEventListener(StatementEventListener listener)
           
 void setExplicitCachingEnabled(boolean cache)
          setExplicitCachingEnabled Enables or disables the explicit cache.
 void setImplicitCachingEnabled(boolean cache)
          setImplicitCachingEnabled Enables or disables the implicit cache.
 void setLastAccessedTime(long lastAccessedTime)
          Set the last accessed time on the PooledConnection.
 void setProperties(Hashtable prop)
           
 void setStatementCacheSize(int size)
          setStatementCacheSize Specifies the size of the size of the application cache (which will be used by both implicit and explicit caching).
 void setStmtCacheSize(int size)
          Deprecated.  
 void setStmtCacheSize(int size, boolean clearMetaData)
          Deprecated.  

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

url_string

public static final String url_string
See Also:
Constant Field Values

pool_auto_commit_string

public static final String pool_auto_commit_string
See Also:
Constant Field Values

object_type_map

public static final String object_type_map
See Also:
Constant Field Values

transaction_isolation

public static final String transaction_isolation
See Also:
Constant Field Values

statement_cache_size

public static final String statement_cache_size
See Also:
Constant Field Values

isClearMetaData

public static final String isClearMetaData
See Also:
Constant Field Values

ImplicitStatementCachingEnabled

public static final String ImplicitStatementCachingEnabled
See Also:
Constant Field Values

ExplicitStatementCachingEnabled

public static final String ExplicitStatementCachingEnabled
See Also:
Constant Field Values

LoginTimeout

public static final String LoginTimeout
See Also:
Constant Field Values

connect_auto_commit_string

public static final String connect_auto_commit_string
See Also:
Constant Field Values

implicit_caching_enabled

public static final String implicit_caching_enabled
See Also:
Constant Field Values

explicit_caching_enabled

public static final String explicit_caching_enabled
See Also:
Constant Field Values

connection_properties_string

public static final String connection_properties_string
See Also:
Constant Field Values

event_listener_string

public static final String event_listener_string
See Also:
Constant Field Values

sql_exception_string

public static final String sql_exception_string
See Also:
Constant Field Values

close_callback_string

public static final String close_callback_string
See Also:
Constant Field Values

private_data

public static final 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

cachedConnectionAttributes

public Properties cachedConnectionAttributes

unMatchedCachedConnAttr

public Properties unMatchedCachedConnAttr

closeOption

public int closeOption

dataSourceInstanceNameKey

protected String dataSourceInstanceNameKey

dataSourceHostNameKey

protected String dataSourceHostNameKey

dataSourceDbUniqNameKey

protected String dataSourceDbUniqNameKey

connectionMarkedDown

protected boolean connectionMarkedDown

needToAbort

protected boolean needToAbort

oracleDriver

protected transient oracle.jdbc.driver.OracleDriver oracleDriver

TRACE

public static final boolean TRACE
See Also:
Constant Field Values

Constructor Detail

OraclePooledConnection

public OraclePooledConnection()

OraclePooledConnection

public OraclePooledConnection(String url)
                       throws SQLException

Creates a PooledConnection.

Parameters:
url - URL of the physical connection.
Throws:
SQLException

OraclePooledConnection

public OraclePooledConnection(String url,
                              String user,
                              String passwd)
                       throws SQLException

Creates a PooledConnection.

Parameters:
url - URL of the physical connection.
user - User Name
passwd - Password
Throws:
SQLException

OraclePooledConnection

public OraclePooledConnection(Connection pc)

Create a Pooled Connection.

Parameters:
pc - The corresponding physical connection.

OraclePooledConnection

public OraclePooledConnection(Connection pc,
                              boolean ac)

Create a Pooled Connection.

Parameters:
pc - The corresponding physical connection
ac - autoCommit value

Method Detail

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener cel)

Add an event listener.

Specified by:
addConnectionEventListener in interface PooledConnection
Parameters:
cel - The listener to be added

close

public void close()
           throws SQLException

Close the physical connection.

Specified by:
close in interface PooledConnection
Throws:
SQLException - if a database-access error occurs.

getConnection

public Connection getConnection()
                         throws SQLException

Create 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:
getConnection in interface PooledConnection
Returns:
a Connection object
Throws:
SQLException - if a database-access error occurs.

getLogicalHandle

public Connection getLogicalHandle()
                            throws SQLException

Return the logical handle to the caller. This logical handle refers to the physical connection that is pooled.

Returns:
a Connection object
Throws:
SQLException

getPhysicalHandle

public Connection getPhysicalHandle()
                             throws SQLException
Throws:
SQLException

setLastAccessedTime

public void setLastAccessedTime(long lastAccessedTime)
                         throws SQLException

Set the last accessed time on the PooledConnection. This is used by the inactivity timeout thread

Parameters:
lastAccessedTime, - last accessed time in milliseconds
Throws:
SQLException

getLastAccessedTime

public long getLastAccessedTime()
                         throws SQLException

Get the last accessed time on the PooledConnection. This is used by the inactivity timeout thread

Returns:
long (milliseconds)
Throws:
SQLException

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener cel)

Remove an event listener.

Specified by:
removeConnectionEventListener in interface PooledConnection
Parameters:
cel - The listener to be removed.

registerImplicitCacheConnectionEventListener

public void registerImplicitCacheConnectionEventListener(ConnectionEventListener cel)

Register an event listener for the implicit connection cache.

Parameters:
cel - The listener to be registered

setStmtCacheSize

public void setStmtCacheSize(int size)
                      throws SQLException
Deprecated. 
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 meta data 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:
SQLException

setStmtCacheSize

public void setStmtCacheSize(int size,
                             boolean clearMetaData)
                      throws SQLException
Deprecated. 
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 meta data 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 Cache
clearMetaData - Whether the state has to be cleared or not
Throws:
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 SQLException
setStatementCacheSize Specifies the size of the size of the application cache (which will be used by both implicit and explicit caching).
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:
SQLException - if size < 0, or if called on a logical connection.

getStatementCacheSize

public int getStatementCacheSize()
                          throws SQLException
getStatementCacheSize Returns the current size of the application cache. This is valid on both physical and logical connections.
Throws:
SQLException

setImplicitCachingEnabled

public void setImplicitCachingEnabled(boolean cache)
                               throws SQLException
setImplicitCachingEnabled Enables or disables the implicit cache. Note that this is independent of the cache size, set with setStatmentCacheSize().
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:
SQLException - if called on a logical connection.

getImplicitCachingEnabled

public boolean getImplicitCachingEnabled()
                                  throws SQLException
getImplicitCachingEnabled Returns true if the implicit cache is currently enabled, false otherwise. This method is valid on both logical and physical connections.
Throws:
SQLException

setExplicitCachingEnabled

public void setExplicitCachingEnabled(boolean cache)
                               throws SQLException
setExplicitCachingEnabled Enables or disables the explicit cache. Note that this is independent of the cache size, set with setStatmentCacheSize().
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:
SQLException - if called on a logical connection.

getExplicitCachingEnabled

public boolean getExplicitCachingEnabled()
                                  throws SQLException
getExplicitCachingEnabled Returns true if the explicit cache is currently enabled, false otherwise. This method is valid on both logical and physical connections.
Throws:
SQLException

purgeImplicitCache

public void purgeImplicitCache()
                        throws SQLException
purgeImplicitCache 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.
Throws:
SQLException

purgeExplicitCache

public void purgeExplicitCache()
                        throws SQLException
purgeExplicitCache 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.
Throws:
SQLException

getStatementWithKey

public PreparedStatement getStatementWithKey(String key)
                                      throws SQLException
getStatementWithKey Searches the explicit cache for a match on key. If found, the statement is returned, with the paramater 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.
Parameters:
key - Specified key to search for
Throws:
SQLException

getCallWithKey

public CallableStatement getCallWithKey(String key)
                                 throws SQLException
getCallWithKey Searches the explicit cache for a match on key. If found, the statement is returned, with the paramater 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.
Parameters:
key - Specified key to search for
Throws:
SQLException

isStatementCacheInitialized

public boolean isStatementCacheInitialized()

setProperties

public final void setProperties(Hashtable prop)

getXAResource

public XAResource getXAResource()
                         throws SQLException
Return an XA resource to the caller. This is just a placeholder. Only the one on XAConnection is meaningful.
Returns:
the XAResource (null if error occurs)
Throws:
SQLException - if a database error occurs

addStatementEventListener

public void addStatementEventListener(StatementEventListener listener)
Specified by:
addStatementEventListener in interface PooledConnection

removeStatementEventListener

public void removeStatementEventListener(StatementEventListener listener)
Specified by:
removeStatementEventListener in interface PooledConnection

getConnectionDuringExceptionHandling

protected oracle.jdbc.internal.OracleConnection getConnectionDuringExceptionHandling()

Skip navigation links

Oracle®Database JDBC Java API Reference
12c Release 1 (12.1.0.2)
E56669-01


Copyright © 2008, 2014, Oracle and/or its affiliates. All rights reserved.