net.xoetrope.optional.data.sql
Class ConnectionManager

java.lang.Object
  extended by net.xoetrope.optional.pool.PoolManager
      extended by net.xoetrope.optional.data.sql.ConnectionManager
Direct Known Subclasses:
NamedConnectionManager

public class ConnectionManager
extends PoolManager

A class that acts as a Connection Pool manager. Used when an application connects directly with a database. XUI allows databases and connections to be configured from XML. The connections canthen be used to load tables into the model as DatabaseTableModel or for execution of custom queries at runtime.

Copyright (c) Xoetrope Ltd. 2001-2003

$Revision: 2.3 $ License: see license.txt


Field Summary
protected static ConnectionManager connMgr
           
protected static java.lang.String defaultDatabaseUrl
           
protected static java.lang.String defaultDriverName
           
protected  java.lang.String password
           
protected  java.lang.String url
           
protected  java.lang.String user
           
 
Fields inherited from class net.xoetrope.optional.pool.PoolManager
objects
 
Constructor Summary
protected ConnectionManager(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
 ConnectionObject getConnection(java.lang.String connName)
          Gets a connection.
static ConnectionManager getInstance()
          Deprecated.  
 PoolObject getNewObject(java.lang.String connName)
          Creates a new ConnectionObject, loading the JDBC driver in the process if necessary
 ConnectionManager reset(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.pool.PoolManager
closeObjects, getObject, reapObjects, returnObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

protected java.lang.String url

user

protected java.lang.String user

password

protected java.lang.String password

defaultDriverName

protected static java.lang.String defaultDriverName

defaultDatabaseUrl

protected static java.lang.String defaultDatabaseUrl

connMgr

protected static ConnectionManager connMgr
Constructor Detail

ConnectionManager

protected ConnectionManager(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:
adriver - the database driver name
aurl - the database connection string
auser - the database user
apassword - the database password
size - the initial pool size
Method Detail

getNewObject

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

Specified by:
getNewObject in class PoolManager
Parameters:
connName - the connection name, ignored for this the default connection manager as only a single instance of the default connection is used.
Returns:
the named connection manager or a new manager if none previously existed
Throws:
java.sql.SQLException - if an connection could not be established, for instance if the driver could not be loaded and instantiated

getInstance

public static ConnectionManager getInstance()
Deprecated. 

Gets an instance of the ConnectionManager

Returns:
the connection manager instance

reset

public ConnectionManager reset(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. The method is useful if the configuration of the database changes and needs to be reestablished

Parameters:
driver - the database driver name
url - the database URL
userName - the user name/account name by which to access the database
password - the database password
Returns:
the new manager

getConnection

public ConnectionObject getConnection(java.lang.String connName)
                               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.

Parameters:
connName - the connection name or null if none exists
Returns:
ConnectionObject
Throws:
java.sql.SQLException - possible exceptions while trying to establish the connection.