ca.bc.gov.webade.dbpool
Class WebADEConnectionCache

java.lang.Object
  extended byca.bc.gov.webade.dbpool.WebADEConnectionCache
All Implemented Interfaces:
javax.sql.ConnectionEventListener, javax.sql.ConnectionPoolDataSource, java.util.EventListener

public class WebADEConnectionCache
extends java.lang.Object
implements javax.sql.ConnectionPoolDataSource, javax.sql.ConnectionEventListener

Creates a pool of oracle database connections.

Author:
jross

Constructor Summary
WebADEConnectionCache(java.lang.String poolName, ConnectionPoolParams params)
           
WebADEConnectionCache(java.lang.String poolName, java.util.Properties initProperties)
           
 
Method Summary
 void close()
          Closes all the pooled connections gacefully.
 void closePooledConnection(javax.sql.PooledConnection pconn)
          Closes the pooled connections gacefully and remove it from the cache.
 void connectionClosed(javax.sql.ConnectionEvent event)
           
 void connectionErrorOccurred(javax.sql.ConnectionEvent event)
           
 void dispose()
          Closes all the pooled connections gracefully on dispose.
 java.sql.Connection getConnection()
           
 int getCurrentConnections()
           
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 long getMaxCheckoutTime()
           
 int getMaxConnections()
           
 long getMaxIdleTime()
           
 long getMaxWaitTime()
           
 int getMinConnections()
           
 int getOverdueConnectionCount()
           
 javax.sql.PooledConnection getPooledConnection()
           
 javax.sql.PooledConnection getPooledConnection(java.lang.String arg0, java.lang.String arg1)
           
 java.lang.String getRoleName()
           
 java.lang.String getURL()
           
 java.lang.String getUser()
           
 void reusePooledConnection(javax.sql.PooledConnection pconn)
          Return the pooled connection to the pool and mark as available.
 void setLoginTimeout(int arg0)
           
 void setLogWriter(java.io.PrintWriter arg0)
           
 void setMaxCheckoutTime(long newMaxCheckoutTime)
           
 void setMaxConnections(int newMaxLimit)
           
 void setMaxIdleTime(long newMaxIdleTime)
           
 void setMaxWaitTime(long newMaxWaitTime)
           
 void setMinConnections(int newMinLimit)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebADEConnectionCache

public WebADEConnectionCache(java.lang.String poolName,
                             java.util.Properties initProperties)
                      throws java.sql.SQLException,
                             ConnectionPoolInitializationException
Parameters:
poolName -
initProperties -
Throws:
java.sql.SQLException
ConnectionPoolInitializationException

WebADEConnectionCache

public WebADEConnectionCache(java.lang.String poolName,
                             ConnectionPoolParams params)
                      throws java.sql.SQLException,
                             ConnectionPoolInitializationException
Parameters:
poolName -
params -
Throws:
java.sql.SQLException
ConnectionPoolInitializationException
Method Detail

connectionClosed

public void connectionClosed(javax.sql.ConnectionEvent event)
Specified by:
connectionClosed in interface javax.sql.ConnectionEventListener
See Also:
ConnectionEventListener.connectionClosed(javax.sql.ConnectionEvent)

connectionErrorOccurred

public void connectionErrorOccurred(javax.sql.ConnectionEvent event)
Specified by:
connectionErrorOccurred in interface javax.sql.ConnectionEventListener
See Also:
ConnectionEventListener.connectionErrorOccurred(javax.sql.ConnectionEvent)

close

public void close()
           throws java.sql.SQLException
Closes all the pooled connections gacefully.

Throws:
java.sql.SQLException

closePooledConnection

public void closePooledConnection(javax.sql.PooledConnection pconn)
                           throws java.sql.SQLException
Closes the pooled connections gacefully and remove it from the cache.

Parameters:
pconn -
Throws:
java.sql.SQLException

reusePooledConnection

public void reusePooledConnection(javax.sql.PooledConnection pconn)
                           throws java.sql.SQLException
Return the pooled connection to the pool and mark as available.

Parameters:
pconn -
Throws:
java.sql.SQLException

getPooledConnection

public javax.sql.PooledConnection getPooledConnection()
                                               throws java.sql.SQLException
Specified by:
getPooledConnection in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.getPooledConnection()

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Returns:
A connection from the pool.
Throws:
java.sql.SQLException

getPooledConnection

public javax.sql.PooledConnection getPooledConnection(java.lang.String arg0,
                                                      java.lang.String arg1)
                                               throws java.sql.SQLException
Specified by:
getPooledConnection in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.getPooledConnection(java.lang.String, java.lang.String)

getRoleName

public java.lang.String getRoleName()
Returns:
Returns the WebADE rolename that owns this connection pool.

getURL

public java.lang.String getURL()
Returns:
Returns the URL.

getUser

public java.lang.String getUser()
Returns:
Returns the user.

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.getLoginTimeout()

setLoginTimeout

public void setLoginTimeout(int arg0)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.setLoginTimeout(int)

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.getLogWriter()

setLogWriter

public void setLogWriter(java.io.PrintWriter arg0)
                  throws java.sql.SQLException
Specified by:
setLogWriter in interface javax.sql.ConnectionPoolDataSource
Throws:
java.sql.SQLException
See Also:
ConnectionPoolDataSource.setLogWriter(java.io.PrintWriter)

toString

public java.lang.String toString()
See Also:
Object.toString()

getCurrentConnections

public int getCurrentConnections()
Returns:
The number of connections currently in the pool.

getOverdueConnectionCount

public int getOverdueConnectionCount()
Returns:
The number of connections that are checked out and overdue.

getMinConnections

public int getMinConnections()
Returns:
The minimum number of connection this pool can have.

setMinConnections

public void setMinConnections(int newMinLimit)
Parameters:
newMinLimit -

getMaxConnections

public int getMaxConnections()
Returns:
The maximum number of connection this pool can have.

setMaxConnections

public void setMaxConnections(int newMaxLimit)
Parameters:
newMaxLimit -

getMaxWaitTime

public long getMaxWaitTime()
Returns:
The maximum time a thread will wait for a connection from this pool.

setMaxWaitTime

public void setMaxWaitTime(long newMaxWaitTime)
Parameters:
newMaxWaitTime -

getMaxIdleTime

public long getMaxIdleTime()
Returns:
The maximum time a connection will remain idle in the pool before being closed.

setMaxIdleTime

public void setMaxIdleTime(long newMaxIdleTime)
Parameters:
newMaxIdleTime -

getMaxCheckoutTime

public long getMaxCheckoutTime()
Returns:
The maximum time a connection can remain checked out before becoming idle.

setMaxCheckoutTime

public void setMaxCheckoutTime(long newMaxCheckoutTime)
Parameters:
newMaxCheckoutTime -

dispose

public void dispose()
             throws java.sql.SQLException
Closes all the pooled connections gracefully on dispose.

Throws:
java.sql.SQLException