org.aitools.programd.util.sql
Class DbAccessRefsPoolMgr

java.lang.Object
  extended by org.aitools.programd.util.sql.ObjectPool
      extended by org.aitools.programd.util.sql.DbAccessRefsPoolMgr

public class DbAccessRefsPoolMgr
extends ObjectPool

Manages a pool of references to a database.

Author:
Cristian Mircioiu

Field Summary
protected  java.lang.String driver
          The name of the driver used by this object.
protected  java.lang.String password
          The password used by this object.
protected  java.lang.String url
          The URL string used by this object.
protected  java.lang.String user
          The user name used by this object.
 
Constructor Summary
DbAccessRefsPoolMgr(java.lang.String driverToUse, java.lang.String urlToUse, java.lang.String userToUse, java.lang.String passwordToUse)
          Constructs a DbAccessRefsPoolMgr object given a driver, url, user name and password.
 
Method Summary
protected  java.lang.Object create()
          Initializes the object by attempting to get a DbAccess object based on the parameters set.
protected  void expire(java.lang.Object o)
          Expires an object in the pool.
 void populate(int connectionCount)
          Builds a pool of the specified number of connections.
 void returnDbaRef(DbAccess dba)
          Checks back in and locks a DbAccess reference to the database.
 DbAccess takeDbaRef()
          Checks out and unlocks a DbAccess reference to the database.
protected  boolean validate(java.lang.Object o)
          Validates an object in the pool.
 
Methods inherited from class org.aitools.programd.util.sql.ObjectPool
cleanUp, checkIn, checkOut
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

driver

protected java.lang.String driver
The name of the driver used by this object.


url

protected java.lang.String url
The URL string used by this object.


user

protected java.lang.String user
The user name used by this object.


password

protected java.lang.String password
The password used by this object.

Constructor Detail

DbAccessRefsPoolMgr

public DbAccessRefsPoolMgr(java.lang.String driverToUse,
                           java.lang.String urlToUse,
                           java.lang.String userToUse,
                           java.lang.String passwordToUse)
Constructs a DbAccessRefsPoolMgr object given a driver, url, user name and password.

Parameters:
driverToUse - name of the class representing the Driver to be used by the Driver manager
urlToUse - location of a data source name (dsn)
userToUse - user name
passwordToUse - password for user
Method Detail

create

protected java.lang.Object create()
Initializes the object by attempting to get a DbAccess object based on the parameters set.

Specified by:
create in class ObjectPool
Returns:
the created object

populate

public void populate(int connectionCount)
Builds a pool of the specified number of connections.

Parameters:
connectionCount - the number of connections to create

returnDbaRef

public void returnDbaRef(DbAccess dba)
Checks back in and locks a DbAccess reference to the database.

Parameters:
dba - the reference to return

takeDbaRef

public DbAccess takeDbaRef()
Checks out and unlocks a DbAccess reference to the database.

Returns:
a reference to the database

validate

protected boolean validate(java.lang.Object o)
Description copied from class: ObjectPool
Validates an object in the pool.

Specified by:
validate in class ObjectPool
Parameters:
o - the object to validate
Returns:
whether or not the object validates

expire

protected void expire(java.lang.Object o)
Description copied from class: ObjectPool
Expires an object in the pool.

Specified by:
expire in class ObjectPool
Parameters:
o - the object to expire