oracle.jdbc.pool
Class OracleConnectionCacheImpl

java.lang.Object
  |
  +--oracle.jdbc.pool.OracleDataSource
        |
        +--oracle.jdbc.pool.OracleConnectionCacheImpl

public class OracleConnectionCacheImpl
extends OracleDataSource
implements OracleConnectionCache, java.io.Serializable, javax.naming.Referenceable

See Also:
Serialized Form

Field Summary
static int DYNAMIC_SCHEME
           
static int FIXED_RETURN_NULL_SCHEME
           
static int FIXED_WAIT_SCHEME
           
 
Constructor Summary
OracleConnectionCacheImpl()
           Default Constructor.
OracleConnectionCacheImpl(javax.sql.ConnectionPoolDataSource ds)
           Create an OracleConnectionCacheImpl with the given ConnectionPoolDataSource from which PooledConnections have to created.
 
Method Summary
 void close()
           Physically close all the pooled connections in the cache and free all the resources.
 void closePooledConnection(javax.sql.PooledConnection pc)
           Invoked by the ConnectionEventListener when an error occurs on a PooledConnection/LogicalConnection signaling that it is no longer good to be used and can be closed.
 int getActiveSize()
          Return the total no of connections that are being used.
 int getCacheScheme()
          Return the Caching Scheme being used.
 int getCacheSize()
          Return the total no of connections in the Cache.
 java.sql.Connection getConnection()
          Attempt to get a logical connection from the Cache.
 java.sql.Connection getConnection(java.lang.String user, java.lang.String passwd)
          Attempt to get a logical connection from the Cache.
 int getMaxLimit()
          Return the Max limit on Connections.
 int getMinLimit()
          Return the minimum limit on the no of Connections.
 javax.naming.Reference getReference()
           
 int getStmtCacheSize()
          Return the size of Statement Cache.
 void reusePooledConnection(javax.sql.PooledConnection pc)
           Invoked by the ConnectionEventListener instance when Logical connection handles are closed signaling that the PooledConnection can be recycled into the pool for further use.
 void setCacheScheme(int s)
          Set the Scheme for this Cache.
 void setConnectionPoolDataSource(javax.sql.ConnectionPoolDataSource ds)
          Associate a ConnectionPoolDataSource datasource to the Cache.
 void setMaxLimit(int l)
          Set the maximum no of connections for the Cache.
 void setMinLimit(int l)
          Set the minimum no of connections for the Cache.
 void setStmtCacheSize(int size)
          Set the statement cache size.
 void setStmtCacheSize(int size, boolean clearMetaData)
          Set the statement cache size.
 
Methods inherited from class oracle.jdbc.pool.OracleDataSource
getDatabaseName, getDataSourceName, getDescription, getDriverType, getLoginTimeout, getLogWriter, getNetworkProtocol, getPortNumber, getServerName, getTNSEntryName, getURL, getUser, setDatabaseName, setDataSourceName, setDescription, setDriverType, setLoginTimeout, setLogWriter, setNetworkProtocol, setPassword, setPortNumber, setServerName, setTNSEntryName, setURL, setUser
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DYNAMIC_SCHEME

public static final int DYNAMIC_SCHEME

FIXED_WAIT_SCHEME

public static final int FIXED_WAIT_SCHEME

FIXED_RETURN_NULL_SCHEME

public static final int FIXED_RETURN_NULL_SCHEME
Constructor Detail

OracleConnectionCacheImpl

public OracleConnectionCacheImpl()
                          throws java.sql.SQLException

Default Constructor. Should have an explicit call to set the URL, User, Password and other DataSource details. A ConnectionPoolDataSource is created with these options from which PooledConnections can be created.

Throws:
java.sql.SQLException - error creating Cache

OracleConnectionCacheImpl

public OracleConnectionCacheImpl(javax.sql.ConnectionPoolDataSource ds)
                          throws java.sql.SQLException

Create an OracleConnectionCacheImpl with the given ConnectionPoolDataSource from which PooledConnections have to created. In which case, url, user name, password, and other DataSource properties set on this Cache are ignored.

Parameters:
ds - a datasource from which the Cache can create PooledConnections.
Throws:
java.sql.SQLException - error creating Cache
Method Detail

setConnectionPoolDataSource

public void setConnectionPoolDataSource(javax.sql.ConnectionPoolDataSource ds)
                                 throws java.sql.SQLException
Associate a ConnectionPoolDataSource datasource to the Cache. If one already exists and Connections are already opened then an Exception is thrown. If no connections are opened, then the new ConnectionPoolDataSource overwrites the previous one.
Parameters:
ds - a datasource from which the Cache can create PooledConnections.
Throws:
java.sql.SQLException - A ConnectionPoolDataSource object already exists and connections are already open.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Attempt to get a logical connection from the Cache. May return null depending upon the Schemes selected. Either a ConnectionPoolDataSource must be Set or url, username, password or Other JNDI attributes should be set on this Cache before you attempt to open Connections.
Returns:
Connection A logical Connection Object.
Throws:
java.sql.SQLException - error creating Connection Object.
Overrides:
getConnection in class OracleDataSource

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String passwd)
                                  throws java.sql.SQLException
Attempt to get a logical connection from the Cache. May return null depending upon the Schemes selected. User and password arguments should match the one given either directly or from ConnectionPoolDataSource.
Returns:
Connection A logical Connection Object.
Throws:
java.sql.SQLException - error creating Connection Object.
Overrides:
getConnection in class OracleDataSource

reusePooledConnection

public void reusePooledConnection(javax.sql.PooledConnection pc)
                           throws java.sql.SQLException

Invoked by the ConnectionEventListener instance when Logical connection handles are closed signaling that the PooledConnection can be recycled into the pool for further use.

Specified by:
reusePooledConnection in interface OracleConnectionCache
Parameters:
pc - The pooled connection object that needs to be recylced.
Throws:
java.sql.SQLException - error in recycling the PooledConnection.

closePooledConnection

public void closePooledConnection(javax.sql.PooledConnection pc)
                           throws java.sql.SQLException

Invoked by the ConnectionEventListener when an error occurs on a PooledConnection/LogicalConnection signaling that it is no longer good to be used and can be closed.

Specified by:
closePooledConnection in interface OracleConnectionCache
Parameters:
pc - The pooled connection object that has to be closed because of an error.
Throws:
java.sql.SQLException - error in closing the PooledConnection

close

public void close()
           throws java.sql.SQLException

Physically close all the pooled connections in the cache and free all the resources.

Specified by:
close in interface OracleConnectionCache
Throws:
java.sql.SQLException - error in closing the PooledConnection

setMinLimit

public void setMinLimit(int l)
                 throws java.sql.SQLException
Set the minimum no of connections for the Cache.
Parameters:
l - Minimum no. of Connections.

getMinLimit

public int getMinLimit()
Return the minimum limit on the no of Connections.
Returns:
minimum limit on the no of Connections.

setMaxLimit

public void setMaxLimit(int l)
                 throws java.sql.SQLException
Set the maximum no of connections for the Cache.
Parameters:
l - maximum no. of Connections.

getMaxLimit

public int getMaxLimit()
Return the Max limit on Connections.

Returns:
int Max no of Connections that can be opened.

getCacheScheme

public int getCacheScheme()
Return the Caching Scheme being used.
Returns:
the caching scheme.

setCacheScheme

public void setCacheScheme(int s)
                    throws java.sql.SQLException
Set the Scheme for this Cache. Possible values are OracleConnectionCacheImpl.DYNAMIC_SCHEME OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME
Parameters:
int - Caching Scheme

getActiveSize

public int getActiveSize()
Return the total no of connections that are being used.
Returns:
total no of active connections.

getCacheSize

public int getCacheSize()
Return the total no of connections in the Cache.
Returns:
total no of connections opened.

getReference

public javax.naming.Reference getReference()
                                    throws javax.naming.NamingException
Specified by:
getReference in interface javax.naming.Referenceable
Overrides:
getReference in class OracleDataSource

setStmtCacheSize

public void setStmtCacheSize(int size)
                      throws java.sql.SQLException
Set the statement cache size. Default is 0. You cannot set 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
Set the statement cache size. Default is 0. You cannot set 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()
Return the size of Statement Cache.
Returns:
int Size of Statement Cache. If not set, the default 0 is returned.