com.ge.research.utils.db
Class DDConnectionBrokerWrapper

java.lang.Object
  extended bycom.ge.research.utils.db.DDConnectionBrokerWrapper
All Implemented Interfaces:
java.lang.Cloneable, ConnectionBroker, javax.sql.DataSource

public class DDConnectionBrokerWrapper
extends java.lang.Object
implements ConnectionBroker, java.lang.Cloneable

DOCUMENT ME!

Author:
garbiras

Field Summary
 
Fields inherited from interface com.ge.research.utils.db.ConnectionBroker
DB_ATTEMPTS_KEY, DB_CONNTIMEOUT_KEY, DB_DRIVER_KEY, DB_MAXCONN_KEY, DB_MINCONN_KEY, DB_PWD_KEY, DB_URL_KEY, DB_USERNAME_KEY, DB_WAITTIME_KEY, MAX_CONNECTIONS, MIN_CONNECTIONS
 
Constructor Summary
DDConnectionBrokerWrapper(java.lang.String resourceFile)
          Default Constructor.
DDConnectionBrokerWrapper(java.lang.String driver, java.lang.String url, java.lang.String username, java.lang.String password, int minConnections, int maxConnections, long timeout, long leaseTime, java.lang.String logFile)
          Creates a DDConnectionBroker pool manager from the argument information.
 
Method Summary
 java.lang.Object clone()
          Creates a copy of the connection broker, with the current settings for pooling variables.
 void freeConnection(java.sql.Connection c)
          Returns the connection from use and releases it back tot he pool of available connections which can be accessed by requestors.
 java.sql.Connection getConnection()
           
 java.sql.Connection getConnection(java.lang.String user, java.lang.String password)
           
 java.lang.String getDriver()
          Returns the current setting of the database connection driver.
 long getLeaseTime()
          Returns the current setting of the connection lease time.
 java.lang.String getLogFile()
          Returns the current setting of the log file to use for writing out pooling messages.
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 int getMaxConnections()
          Returns the current setting for the maximum allowable size of the connection pool.
 int getMaxDbAttempts()
          Returns the current setting for the maximum number of consecutive attempts at requesting a connection from the pool (without obtaining a free connection), before generating an error.
 int getMinConnections()
          Returns the current setting for the minimum allowable size of the connection pool.
 int getNumberFreeConnections()
          Returns the number of currently free and available connections in the pool
 java.lang.String getPassword()
          Returns the current setting of the database connection password.
 long getTimeout()
          Returns the current setting for the number of milliseconds to keep pooled connections not in use active and open.
 java.lang.String getUrl()
          Returns the current setting of the database connection url.
 java.lang.String getUsername()
          Returns the current setting of the database connection username.
 void setDriver(java.lang.String string)
          Sets the database driver to use to connect to the database.
 void setLeaseTime(long l)
          Sets the connection lease time limit.
 void setLogFile(java.lang.String string)
          Sets the log file to use for writing out pooling messages.
 void setLoginTimeout(int i)
           
 void setLogWriter(java.io.PrintWriter out)
           
 void setMaxConnections(int i)
          Sets the maximum allowable size of the connection pool.
 void setMaxDbAttempts(int i)
          Sets the maximum number of consecutive attempts allowed when requesting a connection from the pool (without obtaining a free connection), before generating an error.
 void setMinConnections(int i)
          Sets the minimum allowable size of the connection pool.
 void setPassword(java.lang.String string)
          Sets the database password to use to connect to the database.
 void setTimeout(long l)
          Sets the number of milliseconds to keep pooled connections not in use active and open.
 void setUrl(java.lang.String string)
          Sets the database url to use to connect to the database.
 void setUsername(java.lang.String string)
          Sets the database username to use to connect to the database.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DDConnectionBrokerWrapper

public DDConnectionBrokerWrapper(java.lang.String resourceFile)
                          throws java.sql.SQLException,
                                 java.lang.Exception
Default Constructor. Loads database connection information from a resource file and creates a DDConnectionBroker pool manager.

Parameters:
resourceFile - the resource bundle name
Throws:
java.lang.Exception - If the resource bundle information could not be loaded.
java.sql.SQLException - If the DDConnectionBroker could not be created.

DDConnectionBrokerWrapper

public DDConnectionBrokerWrapper(java.lang.String driver,
                                 java.lang.String url,
                                 java.lang.String username,
                                 java.lang.String password,
                                 int minConnections,
                                 int maxConnections,
                                 long timeout,
                                 long leaseTime,
                                 java.lang.String logFile)
                          throws java.sql.SQLException
Creates a DDConnectionBroker pool manager from the argument information.

Parameters:
driver - the database driver class to use to connect to the database
url - the database url to use to connect to the database
username - the database username authentication to use to connect to the database
password - the database password authentication to use to connect to the database
minConnections - the minimum sie of the connection pool
maxConnections - the maximum size of the connection pool
timeout - the connection timeout interval in milliseconds
leaseTime - the connection lease length in milliseconds
logFile - the logfile to use when writing out pooling messages
Throws:
java.sql.SQLException - If the DDConnectionBroker could not be created.
Method Detail

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setDriver

public void setDriver(java.lang.String string)
Sets the database driver to use to connect to the database. This does not change the current broker's connection information, but does affect this property for cloning purposes.

Parameters:
string - the database driver to use to connect to the database

getDriver

public java.lang.String getDriver()
Returns the current setting of the database connection driver. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The database driver to use to connect to the database

setUrl

public void setUrl(java.lang.String string)
Sets the database url to use to connect to the database. This does not change the current broker's connection information, but does affect this property for cloning purposes.

Parameters:
string - the database url to use to connect to the database

getUrl

public java.lang.String getUrl()
Returns the current setting of the database connection url. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The database url to use to connect to the database

setUsername

public void setUsername(java.lang.String string)
Sets the database username to use to connect to the database. This does not change the current broker's connection information, but does affect this property for cloning purposes.

Parameters:
string - the database username to use to connect to the database

getUsername

public java.lang.String getUsername()
Returns the current setting of the database connection username. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The database username to use to connect to the database

setPassword

public void setPassword(java.lang.String string)
Sets the database password to use to connect to the database. This does not change the current broker's connection information, but does affect this property for cloning purposes.

Parameters:
string - the database password to use to connect to the database

getPassword

public java.lang.String getPassword()
Returns the current setting of the database connection password. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The database password to use to connect to the database

setLeaseTime

public void setLeaseTime(long l)
Sets the connection lease time limit. This does not change the current broker's settings, but does affect this property for cloning purposes.

Parameters:
l - the connection lease time

getLeaseTime

public long getLeaseTime()
Returns the current setting of the connection lease time. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The connection lease time

setLogFile

public void setLogFile(java.lang.String string)
Sets the log file to use for writing out pooling messages. This does not change the current broker's settings, but does affect this property for cloning purposes.

Parameters:
string - the log file to use for writing out pooling messages

getLogFile

public java.lang.String getLogFile()
Returns the current setting of the log file to use for writing out pooling messages. It is not necessarily the same as the one used by the current broker, since that information is setup via the constructor and the local instances of that information can be changed without changing the current broker's settings.

Returns:
The log file to use for writing out pooling messages

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
Specified by:
setLogWriter in interface javax.sql.DataSource

getLogWriter

public java.io.PrintWriter getLogWriter()
Specified by:
getLogWriter in interface javax.sql.DataSource

setLoginTimeout

public void setLoginTimeout(int i)
Specified by:
setLoginTimeout in interface javax.sql.DataSource

getLoginTimeout

public int getLoginTimeout()
Specified by:
getLoginTimeout in interface javax.sql.DataSource

setMaxConnections

public void setMaxConnections(int i)
Description copied from interface: ConnectionBroker
Sets the maximum allowable size of the connection pool.

Specified by:
setMaxConnections in interface ConnectionBroker
Parameters:
i - the maximum allowable size of the connection pool

getMaxConnections

public int getMaxConnections()
Description copied from interface: ConnectionBroker
Returns the current setting for the maximum allowable size of the connection pool.

Specified by:
getMaxConnections in interface ConnectionBroker
Returns:
The maximum allowable size of the connection pool

setMaxDbAttempts

public void setMaxDbAttempts(int i)
Description copied from interface: ConnectionBroker
Sets the maximum number of consecutive attempts allowed when requesting a connection from the pool (without obtaining a free connection), before generating an error.

Specified by:
setMaxDbAttempts in interface ConnectionBroker
Parameters:
i - the maximum number of attempts to obtain a free connection from the pool

getMaxDbAttempts

public int getMaxDbAttempts()
Description copied from interface: ConnectionBroker
Returns the current setting for the maximum number of consecutive attempts at requesting a connection from the pool (without obtaining a free connection), before generating an error.

Specified by:
getMaxDbAttempts in interface ConnectionBroker
Returns:
The maximum number of attempts to obtain a free connection from the pool

setMinConnections

public void setMinConnections(int i)
Description copied from interface: ConnectionBroker
Sets the minimum allowable size of the connection pool.

Specified by:
setMinConnections in interface ConnectionBroker
Parameters:
i - the minimum allowable size of the connection pool

getMinConnections

public int getMinConnections()
Description copied from interface: ConnectionBroker
Returns the current setting for the minimum allowable size of the connection pool.

Specified by:
getMinConnections in interface ConnectionBroker
Returns:
The minimum allowable size of the connection pool

clone

public java.lang.Object clone()
Creates a copy of the connection broker, with the current settings for pooling variables.

Returns:
A copy of the connection broker, or null if a new connection broker could not be instantiated.

setTimeout

public void setTimeout(long l)
Description copied from interface: ConnectionBroker
Sets the number of milliseconds to keep pooled connections not in use active and open.

Specified by:
setTimeout in interface ConnectionBroker
Parameters:
l - the number of milliseconds to keep pooled connections not in use active and open

getTimeout

public long getTimeout()
Description copied from interface: ConnectionBroker
Returns the current setting for the number of milliseconds to keep pooled connections not in use active and open.

Specified by:
getTimeout in interface ConnectionBroker
Returns:
The number of milliseconds to keep pooled connections not in use active and open

freeConnection

public void freeConnection(java.sql.Connection c)
Description copied from interface: ConnectionBroker
Returns the connection from use and releases it back tot he pool of available connections which can be accessed by requestors.

Specified by:
freeConnection in interface ConnectionBroker
Parameters:
c - the connection to return to the available pool

getNumberFreeConnections

public int getNumberFreeConnections()
Description copied from interface: ConnectionBroker
Returns the number of currently free and available connections in the pool

Specified by:
getNumberFreeConnections in interface ConnectionBroker
Returns:
The number of currently free and available connections in the pool