oracle.jdbc.pool
Class OraclePooledConnection

oracle.jdbc.pool.OraclePooledConnection

public class OraclePooledConnection

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


Constructor Summary
OraclePooledConnection()
           
OraclePooledConnection(java.sql.Connection pc)
           Create a Pooled Connection.
OraclePooledConnection(java.sql.Connection pc, boolean ac)
           Create a Pooled Connection.
OraclePooledConnection(java.lang.String url)
           Creates a PooledConnection.
OraclePooledConnection(java.lang.String url, java.lang.String user, java.lang.String passwd)
           Creates a PooledConnection.
 
Method Summary
 void addConnectionEventListener(oracle.jdbc.pool.ConnectionEventListener cel)
           Add an event listener.
 void close()
          Close the physical connection.
 java.sql.CallableStatement getCallWithKey(java.lang.String key)
          getCallWithKey Searches the explicit cache for a match on key.
 java.sql.Connection getConnection()
          Create an object handle for this physical connection.
 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.
 java.sql.Connection getLogicalHandle()
          Return the logical handle to the caller.
 int getStatementCacheSize()
          getStatementCacheSize Returns the current size of the application cache.
 java.sql.PreparedStatement getStatementWithKey(java.lang.String key)
          getStatementWithKey Searches the explicit cache for a match on key.
 int getStmtCacheSize()
          Deprecated.  
 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 removeConnectionEventListener(oracle.jdbc.pool.ConnectionEventListener cel)
           Remove an event 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 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.  
 

Constructor Detail

OraclePooledConnection

public OraclePooledConnection()

OraclePooledConnection

public OraclePooledConnection(java.lang.String url)
                       throws java.sql.SQLException

Creates a PooledConnection.

Parameters:
URL - of the physical connection.

OraclePooledConnection

public OraclePooledConnection(java.lang.String url,
                              java.lang.String user,
                              java.lang.String passwd)
                       throws java.sql.SQLException

Creates a PooledConnection.

Parameters:
URL - of the physical connection.
User - Name
Password -  

OraclePooledConnection

public OraclePooledConnection(java.sql.Connection pc)

Create a Pooled Connection.

Parameters:
The - corresponding physical connection.

OraclePooledConnection

public OraclePooledConnection(java.sql.Connection pc,
                              boolean ac)

Create a Pooled Connection.

Parameters:
The - corresponding physical connection
m_autoCommit - value
Method Detail

addConnectionEventListener

public void addConnectionEventListener(oracle.jdbc.pool.ConnectionEventListener cel)

Add an event listener.

Parameters:
The - listener to be added

close

public void close()
           throws java.sql.SQLException

Close the physical connection.

Throws:
java.sql.SQLException - if a database-access error occurs.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.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.

Returns:
a Connection object
Throws:
java.sql.SQLException - if a database-access error occurs.

getLogicalHandle

public java.sql.Connection getLogicalHandle()
                                     throws java.sql.SQLException

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

Returns:
a Connection object
Throws:
java.sql.SQLException -  

setLastAccessedTime

public void setLastAccessedTime(long lastAccessedTime)
                         throws java.sql.SQLException

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

Parameters:
long, - last accessed time in milliseconds
Returns:
void
Throws:
java.sql.SQLException -  

getLastAccessedTime

public long getLastAccessedTime()
                         throws java.sql.SQLException

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

Returns:
long (milliseconds)
Throws:
java.sql.SQLException -  

removeConnectionEventListener

public void removeConnectionEventListener(oracle.jdbc.pool.ConnectionEventListener cel)

Remove an event listener.

Parameters:
The - listener to be removed.

setStmtCacheSize

public void setStmtCacheSize(int size)
                      throws java.sql.SQLException
Deprecated.  
Set the statement cache size. Default is 0. You cannot call this for logicalhandles obtained from PooledConnections.

If more than size 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 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.SQLException
Deprecated.  
Set the statement cache size. Default is 0. You cannot call this for logicalhandles obtained from PooledConnections.

If more than size 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 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:
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.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:
java.sql.SQLException - if size < 0, or if called on a logical connection.

getStatementCacheSize

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

setImplicitCachingEnabled

public void setImplicitCachingEnabled(boolean cache)
                               throws java.sql.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:
java.sql.SQLException - if called on a logical connection.

getImplicitCachingEnabled

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

setExplicitCachingEnabled

public void setExplicitCachingEnabled(boolean cache)
                               throws java.sql.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:
java.sql.SQLException - if called on a logical connection.

getExplicitCachingEnabled

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

purgeImplicitCache

public void purgeImplicitCache()
                        throws java.sql.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.

purgeExplicitCache

public void purgeExplicitCache()
                        throws java.sql.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.

getStatementWithKey

public java.sql.PreparedStatement getStatementWithKey(java.lang.String key)
                                               throws java.sql.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

getCallWithKey

public java.sql.CallableStatement getCallWithKey(java.lang.String key)
                                          throws java.sql.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

isStatementCacheInitialized

public boolean isStatementCacheInitialized()