com.codestudio.util
Class JDBCPool

java.lang.Object
  |
  +--com.codestudio.util.ObjectPool
        |
        +--com.codestudio.util.JDBCPool
All Implemented Interfaces:
javax.sql.ConnectionEventListener, java.util.EventListener, Pool, java.io.Serializable

public class JDBCPool
extends ObjectPool
implements javax.sql.ConnectionEventListener

JDBCPool is an ObjectPool of JDBC connection objects. It is also a javax.sql.ConnectionEventListener, so it can respond to events fired by the PooledConnection implementation, PoolManConnection.

See Also:
Serialized Form

Fields inherited from class com.codestudio.util.ObjectPool
count, lifeguard, locked, logit, metadata, skimmer, unlocked
 
Constructor Summary
JDBCPool(PoolMetaData metad)
           
 
Method Summary
 void checkCredentials(java.lang.String username, java.lang.String password)
           
 void closeAllResources()
          Overriden in order to ensure that JNDI resources are disposed of properly.
static void closeConnection(java.sql.Connection con)
           
static void closeResources(java.sql.Connection con, java.sql.Statement statement, java.sql.ResultSet resultset)
          Static method that closes the Connection, Statement and ResultSets in one place.
static void closeResources(java.sql.Statement statement, java.sql.ResultSet resultSet)
          Static method that closes the statement and result sets in one place; this is here as a convenience to shorten the finally block in statements.
static void closeResultSet(java.sql.ResultSet rs)
          This method closes the given ResultSet.
static void closeStatement(java.sql.Statement statement)
          Closes the given statement.
 void connectionClosed(javax.sql.ConnectionEvent event)
          Responds to a ConnectionClosed ConnectionEvent.
 void connectionErrorOccurred(javax.sql.ConnectionEvent event)
          Responds to an error event.
protected  java.lang.Object create()
          Creates a physical Connection and PooledConnection wrapper for it (a PoolManConnection).
 void deployDataSource()
           
protected  void expire(java.lang.Object o)
          Closes a physical database connection.
 SQLCache getCache()
           
 javax.sql.DataSource getDataSource()
           
 java.lang.String getDriver()
           
 java.lang.String getPassword()
           
 int getTransactionIsolation()
           
 java.lang.String getURL()
           
 java.lang.String getUserName()
           
 void init()
           
 boolean isDataSourceDeployed()
           
 boolean isUsingNativeResults()
           
 int numPooledStatements(java.lang.String sql)
           
 int numStatementPools()
           
 void refreshCache()
          Force the cache to refresh.
 java.sql.Connection requestConnection()
          Retrieves a PooledConnection impl and returns its Handle.
 java.sql.PreparedStatement requestPooledStatement(java.lang.String sql)
           
 void returnConnection(PoolManConnection pcon)
          Returns a connection to the pool.
 void returnPooledStatement(PoolManPreparedStatement ps)
          Retuns a PreparedStatement to the statement pool
 void setCache(SQLCache cache)
          Associates a SQLCache with this pool.
 void setDataSource(PoolManDataSource ds)
          Associates a DataSource view with this pool.
 void undeployDataSource()
           
 boolean usingCache()
          Determine whether or not this pool is using a SQLCache (configured in poolman.xml and disabled by default).
protected  boolean validate(java.lang.Object o)
          Checks to see if the current connection is valid.
 
Methods inherited from class com.codestudio.util.ObjectPool
checkIn, checkOut, checkTimeout, cleanUp, debug, debug, debugMetrics, finalize, getPoolname, log, log, numCheckedInObjects, numCheckedOutObjects, numTotalObjects, requestObject, returnObject, updateLocked
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCPool

public JDBCPool(PoolMetaData metad)
Method Detail

init

public void init()
          throws java.lang.Exception
Overrides:
init in class ObjectPool

setDataSource

public void setDataSource(PoolManDataSource ds)
Associates a DataSource view with this pool.

getDataSource

public javax.sql.DataSource getDataSource()

deployDataSource

public void deployDataSource()

undeployDataSource

public void undeployDataSource()

isDataSourceDeployed

public boolean isDataSourceDeployed()

setCache

public void setCache(SQLCache cache)
Associates a SQLCache with this pool.

getCache

public SQLCache getCache()
Returns:
SQLCache The SQLCache associated with this pool.

usingCache

public boolean usingCache()
Determine whether or not this pool is using a SQLCache (configured in poolman.xml and disabled by default).

refreshCache

public void refreshCache()
Force the cache to refresh.

getDriver

public java.lang.String getDriver()

getURL

public java.lang.String getURL()

getUserName

public java.lang.String getUserName()

getPassword

public java.lang.String getPassword()

getTransactionIsolation

public int getTransactionIsolation()

isUsingNativeResults

public boolean isUsingNativeResults()

checkCredentials

public void checkCredentials(java.lang.String username,
                             java.lang.String password)
                      throws java.sql.SQLException

connectionClosed

public void connectionClosed(javax.sql.ConnectionEvent event)
Responds to a ConnectionClosed ConnectionEvent.
Specified by:
connectionClosed in interface javax.sql.ConnectionEventListener

connectionErrorOccurred

public void connectionErrorOccurred(javax.sql.ConnectionEvent event)
Responds to an error event.
Specified by:
connectionErrorOccurred in interface javax.sql.ConnectionEventListener

create

protected java.lang.Object create()
                           throws java.sql.SQLException
Creates a physical Connection and PooledConnection wrapper for it (a PoolManConnection).
Overrides:
create in class ObjectPool

validate

protected boolean validate(java.lang.Object o)
Checks to see if the current connection is valid.
Overrides:
validate in class ObjectPool

expire

protected void expire(java.lang.Object o)
Closes a physical database connection.
Overrides:
expire in class ObjectPool

requestConnection

public java.sql.Connection requestConnection()
                                      throws java.sql.SQLException
Retrieves a PooledConnection impl and returns its Handle.

returnConnection

public void returnConnection(PoolManConnection pcon)
Returns a connection to the pool.

requestPooledStatement

public java.sql.PreparedStatement requestPooledStatement(java.lang.String sql)

returnPooledStatement

public void returnPooledStatement(PoolManPreparedStatement ps)
Retuns a PreparedStatement to the statement pool

numStatementPools

public int numStatementPools()

numPooledStatements

public int numPooledStatements(java.lang.String sql)

closeAllResources

public void closeAllResources()
Overriden in order to ensure that JNDI resources are disposed of properly.
Overrides:
closeAllResources in class ObjectPool

closeResources

public static void closeResources(java.sql.Connection con,
                                  java.sql.Statement statement,
                                  java.sql.ResultSet resultset)
Static method that closes the Connection, Statement and ResultSets in one place.

closeResources

public static void closeResources(java.sql.Statement statement,
                                  java.sql.ResultSet resultSet)
Static method that closes the statement and result sets in one place; this is here as a convenience to shorten the finally block in statements. Both arguments may be null;
Parameters:
statement - the statement to be closed
resultSet - the resultSet to be closed

closeConnection

public static void closeConnection(java.sql.Connection con)

closeStatement

public static void closeStatement(java.sql.Statement statement)
Closes the given statement. It is here to get rid of the extra try block in finally blocks that need to close statements
Parameters:
statement - the statement to be closed. may be null

closeResultSet

public static void closeResultSet(java.sql.ResultSet rs)
This method closes the given ResultSet.
Parameters:
rs - the ResultSet to be closed. May be null.


Copyright © 1999-2001 The Code Studio. All Rights Reserved.