Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ConnectionPoolManager Class Reference

#include <ConnectionPoolManager.h>

List of all members.

Public Methods

 ConnectionPoolManager ()
 Creates a pool that doesn't monitor itself to check for idle/stale connections. More...

virtual ~ConnectionPoolManager ()
 ConnectionPoolManager (int monitorInterval)
 Creates a pool with a monitoring thread that checks the pool to make sure no connections are stale or idle. More...

void addAlias (const nsAReadableString& alias, const nsAReadableString& driver, const nsAReadableString& url, const nsAReadableString& username, const nsAReadableString& password, int maxConn, int idleTimeout, int checkoutTimeout)
 Adds an alias to the pool. More...

void addAlias (const nsAReadableString& alias, const nsAReadableString& driver, const nsAReadableString& url, const nsAReadableString& username, const nsAReadableString& password, int maxConn, int idleTimeout, int checkoutTimeout, int maxCheckout)
 Adds an alias to the pool. More...

void removeAlias (const nsAReadableString& alias)
 Closes all Connections in the pool with the supplied alias. More...

ConnectionPoolgetPool (const nsAReadableString& alias)
 Returns the pool with the supplied alias. More...

void run ()
 Monitors each ConnectionPool and makes sure that no connection has gone idle or has been checked out for too long. More...

Connectionconnect (const nsAReadableString& alias)
 Returns a connection from pool. More...


Private Types

typedef std::map<const nsAReadableString*,
ConnectionPool*, compareARS
mapStringPool

Private Attributes

mapStringPool m_aliasHash
long m_sleepInterval
PRLock* m_mManager


Member Typedef Documentation

typedef std::map<const nsAReadableString*, ConnectionPool*, compareARS> ConnectionPoolManager::mapStringPool [private]
 

Definition at line 173 of file ConnectionPoolManager.h.


Constructor & Destructor Documentation

ConnectionPoolManager::ConnectionPoolManager ( )
 

Creates a pool that doesn't monitor itself to check for idle/stale connections.

Use this constructor only if you know what you're doing and have a good reason to not use the monitor thread.

Definition at line 85 of file ConnectionPoolManager.cpp.

ConnectionPoolManager::~ConnectionPoolManager ( ) [virtual]
 

Definition at line 105 of file ConnectionPoolManager.cpp.

ConnectionPoolManager::ConnectionPoolManager ( int monitorInterval )
 

Creates a pool with a monitoring thread that checks the pool to make sure no connections are stale or idle.

Parameters:
monitorInterval   number of seconds between checks on the pool

Definition at line 96 of file ConnectionPoolManager.cpp.


Member Function Documentation

void ConnectionPoolManager::addAlias ( const nsAReadableString & alias,
const nsAReadableString & driver,
const nsAReadableString & url,
const nsAReadableString & username,
const nsAReadableString & password,
int maxConn,
int idleTimeout,
int checkoutTimeout,
int maxCheckout )
 

Adds an alias to the pool.

This does call Class.forName().newInstance() on the JDBC driver, so you don't have to call that yourself.

idleTimeout and checkoutTimeout are expressed in seconds

Parameters:
alias   Name of the pool
driver   Classname of JDBC driver to use
url   JDBC URL to connect to
username   JDBC username to connect as
password   username's password in the database
maxConn   Maximum number of connections to open; When this limit is reached, threads requesting a connection are queued until a connection becomes available
idleTimeout   Maximum number of seconds a Connection can go unused before it is closed
checkoutTimeout   Maximum number of seconds a Thread can checkout a Connection before it is closed and returned to the pool. This is a protection against the Thread dying and leaving the Connection checked out indefinately
maxCheckout   If this is greater than 0, the number of times a Connection may be checked out before it is closed. Used as a safeguard against cursor leak, which occurs if you don't call ResultSet.close() and Statement.close()

Definition at line 173 of file ConnectionPoolManager.cpp.

void ConnectionPoolManager::addAlias ( const nsAReadableString & alias,
const nsAReadableString & driver,
const nsAReadableString & url,
const nsAReadableString & username,
const nsAReadableString & password,
int maxConn,
int idleTimeout,
int checkoutTimeout )
 

Adds an alias to the pool.

This does call Class.forName().newInstance() on the JDBC driver, so you don't have to call that yourself.

idleTimeout and checkoutTimeout are expressed in seconds

Parameters:
alias   Name of the pool
driver   Classname of JDBC driver to use
url   JDBC URL to connect to
username   JDBC username to connect as
password   username's password in the database
maxConn   Maximum number of connections to open; When this limit is reached, threads requesting a connection are queued until a connection becomes available
idleTimeout   Maximum number of seconds a Connection can go unused before it is closed
checkoutTimeout   Maximum number of seconds a Thread can checkout a Connection before it is closed and returned to the pool. This is a protection against the Thread dying and leaving the Connection checked out indefinately

Definition at line 137 of file ConnectionPoolManager.cpp.

Referenced by px7xpdbc::px7xpdbc().

Connection * ConnectionPoolManager::connect ( const nsAReadableString & alias )
 

Returns a connection from pool.

Returns:
JDBC Connection from pool, or null if url does not start with URL_PREFIX
Exceptions:
SQLException   if no alias is given in the URL or if no pool exists with that alias name

Definition at line 271 of file ConnectionPoolManager.cpp.

ConnectionPool * ConnectionPoolManager::getPool ( const nsAReadableString & alias )
 

Returns the pool with the supplied alias.

Exceptions:
SQLException   if no pool exists for that alias

Definition at line 212 of file ConnectionPoolManager.cpp.

Referenced by connect(), px7xpdbc::getConnection(), and removeAlias().

void ConnectionPoolManager::removeAlias ( const nsAReadableString & alias )
 

Closes all Connections in the pool with the supplied alias.

Exceptions:
SQLException   if no pool exists for that alias

Definition at line 198 of file ConnectionPoolManager.cpp.

void ConnectionPoolManager::run ( )
 

Monitors each ConnectionPool and makes sure that no connection has gone idle or has been checked out for too long.

Definition at line 242 of file ConnectionPoolManager.cpp.


Member Data Documentation

mapStringPool ConnectionPoolManager::m_aliasHash [private]
 

Definition at line 174 of file ConnectionPoolManager.h.

PRLock * ConnectionPoolManager::m_mManager [private]
 

Definition at line 176 of file ConnectionPoolManager.h.

long ConnectionPoolManager::m_sleepInterval [private]
 

Definition at line 175 of file ConnectionPoolManager.h.


The documentation for this class was generated from the following files:
Generated at Tue Sep 12 16:29:49 2000 by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000