net.xoetrope.optional.data.sql
Class NamedConnectionManager

java.lang.Object
  extended by net.xoetrope.optional.pool.PoolManager
      extended by net.xoetrope.optional.data.sql.ConnectionManager
          extended by net.xoetrope.optional.data.sql.NamedConnectionManager

public class NamedConnectionManager
extends ConnectionManager

An extension of the ConnectionManager to manage connections to multiple databases

Copyright: Copyright (c) 2003
License: see license.txt

$Revision: 2.7 $ License: see license.txt


Field Summary
protected  java.util.Vector connectionParameters
          Storage for the various connection parameters
 
Fields inherited from class net.xoetrope.optional.data.sql.ConnectionManager
connMgr, defaultDatabaseUrl, defaultDriverName, password, url, user
 
Fields inherited from class net.xoetrope.optional.pool.PoolManager
objects
 
Constructor Summary
protected NamedConnectionManager(java.lang.String name, java.lang.String aDriver, java.lang.String aurl, java.lang.String auser, java.lang.String apassword, int size)
          Constructs a new ConnectionManager, called by getInstance
 
Method Summary
 void addConnection(java.lang.String name, java.lang.String driver, java.lang.String url, java.lang.String userName, java.lang.String password)
          Gets an instance of the ConnectionManager.
protected  java.lang.Object findConnectionParams(java.lang.String connParamName)
          Find a nameds set of connection parameters
 ConnectionObject getConnection(java.lang.String connectionName)
          Gets a connection.
 java.lang.String[] getConnectionParams(java.lang.String connParamName)
          Get the connection parameters
static ConnectionManager getInstance()
          Deprecated.  
 PoolObject getNewObject(java.lang.String connParamName)
          Creates a new ConnectionObject, loading the JDBC driver in the process if necessary
 PoolObject getObject(java.lang.String connParamName)
          Get a new object from the pool.
 ConnectionManager reset(java.lang.String name, java.lang.String driver, java.lang.String url, java.lang.String userName, java.lang.String password)
          Gets an instance of the ConnectionManager.
 
Methods inherited from class net.xoetrope.optional.data.sql.ConnectionManager
reset
 
Methods inherited from class net.xoetrope.optional.pool.PoolManager
closeObjects, reapObjects, returnObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionParameters

protected java.util.Vector connectionParameters
Storage for the various connection parameters

Constructor Detail

NamedConnectionManager

protected NamedConnectionManager(java.lang.String name,
                                 java.lang.String aDriver,
                                 java.lang.String aurl,
                                 java.lang.String auser,
                                 java.lang.String apassword,
                                 int size)
Constructs a new ConnectionManager, called by getInstance

Parameters:
name - the name of the connection to use
aDriver - the name of the driver to use
aurl - the database connection string
auser - the database user
apassword - the database password
size - the initial pool size
Method Detail

getObject

public PoolObject getObject(java.lang.String connParamName)
                     throws java.lang.Exception
Get a new object from the pool. A lease is granted to the new object

Overrides:
getObject in class PoolManager
Parameters:
connParamName - the name of the connection parameters
Returns:
a new PoolObject
Throws:
java.lang.Exception

getNewObject

public PoolObject getNewObject(java.lang.String connParamName)
                        throws java.sql.SQLException
Creates a new ConnectionObject, loading the JDBC driver in the process if necessary

Overrides:
getNewObject in class ConnectionManager
Parameters:
connParamName - the connection name, ignored for this the default connection manager as only a single instance of the default connection is used.
Returns:
a PoolObject
Throws:
java.sql.SQLException

getInstance

public static ConnectionManager getInstance()
Deprecated. 

Gets an instance of the ConnectionManager

Returns:
a ConnectionManager Object

getConnection

public ConnectionObject getConnection(java.lang.String connectionName)
                               throws java.sql.SQLException
Gets a connection. If you call this method directly you must make sure to expire the ConnectionObject when done by calling the expireLease method on the returned object.

Overrides:
getConnection in class ConnectionManager
Parameters:
connectionName - the name of the connection object
Returns:
the ConnectionObject
Throws:
java.sql.SQLException

addConnection

public void addConnection(java.lang.String name,
                          java.lang.String driver,
                          java.lang.String url,
                          java.lang.String userName,
                          java.lang.String password)
Gets an instance of the ConnectionManager. Any open connections are closed prior to attempting the new connection.

Parameters:
name - the name by which the connection paramenters will be referenced
driver - the driver class name
url - the database URL
userName - the user name
password - the password

findConnectionParams

protected java.lang.Object findConnectionParams(java.lang.String connParamName)
Find a nameds set of connection parameters

Parameters:
connParamName - the name of the set of connection parameters
Returns:
the set or null if nothing is found

reset

public ConnectionManager reset(java.lang.String name,
                               java.lang.String driver,
                               java.lang.String url,
                               java.lang.String userName,
                               java.lang.String password)
Gets an instance of the ConnectionManager. Any open connections are closed prior to attempting the new connection.

Parameters:
name - the name of the connection being requested
driver - the driver to be used
userName - the database user
password - the users password
Returns:
the ConnectionManager

getConnectionParams

public java.lang.String[] getConnectionParams(java.lang.String connParamName)
Get the connection parameters

Parameters:
connParamName - the name of the set of connection parameters
Returns:
the connection parameters strings