com.raritantechnologies.searchApp.database
Class ConnectionPool

java.lang.Object
  extended bycom.raritantechnologies.searchApp.database.ConnectionPool
All Implemented Interfaces:
IConfigurable, IDatabaseConnectionManager

public class ConnectionPool
extends java.lang.Object
implements IDatabaseConnectionManager

Implementation of ConnectionManager that can do its own connection pooling.

XML Configuration Template:
   <SystemObject type="DatabaseConnectionManager" name="[my name]"
                    class="com.raritantechnologies.searchApp.database.ConnectionPool"
                    driver="[JDBC driver class]"
                    name="[DB name]"
                    userName="[db user]"
                    password="[db password]"
                    URL="[jdbc url]"
                    initConnections="2"
                    maxConnections="5"
                    timeout="3"
                    instanceType="single" />  <!-- singleton is pretty much a requirement for this -->
 

Developed by Raritan Technologies .

Author:
Ted Sullivan

Constructor Summary
ConnectionPool()
           
ConnectionPool(java.lang.String strName, java.lang.String strURL, java.lang.String strUser, java.lang.String strPassword, int iMaxConns, int iInitConns, int iTimeout)
           
ConnectionPool(java.lang.String strName, java.lang.String strURL, java.lang.String strUser, java.lang.String strPassword, int iMaxConns, int iInitConns, int iTimeout, java.lang.String driverClass)
           
 
Method Summary
 void closeConnection(java.sql.Connection conn)
           
 void finalize()
          Called by the JVM Garbage Collector: release all connections.
 java.sql.Connection getConnection()
          returns a java.sql.Connection object wrapped in a ConnectionWrapper.
 void initialize(org.w3c.dom.Element elem)
          Initializes the object from an XML tag or element.
 void release()
          releases all connections.
 void wrapperClosed(java.sql.Connection conn)
          returns a Connection object to the ConnectionPool for reuse.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionPool

public ConnectionPool()

ConnectionPool

public ConnectionPool(java.lang.String strName,
                      java.lang.String strURL,
                      java.lang.String strUser,
                      java.lang.String strPassword,
                      int iMaxConns,
                      int iInitConns,
                      int iTimeout)

ConnectionPool

public ConnectionPool(java.lang.String strName,
                      java.lang.String strURL,
                      java.lang.String strUser,
                      java.lang.String strPassword,
                      int iMaxConns,
                      int iInitConns,
                      int iTimeout,
                      java.lang.String driverClass)
Method Detail

initialize

public void initialize(org.w3c.dom.Element elem)
Description copied from interface: IConfigurable
Initializes the object from an XML tag or element. This method is called by the Framework as part of the application initializtion. see ConfigurationManager, XMLConfigurationManager, XMLSearchFieldMapFactory, XMLSearchSourceFactory. Configurable objects that are owned or contained by other configurable objects will be initialized in by the parent object.

Specified by:
initialize in interface IConfigurable

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
returns a java.sql.Connection object wrapped in a ConnectionWrapper. When this Connection is closed, the ConnectionWrapper returns it to this ConnectionPool.

Specified by:
getConnection in interface IDatabaseConnectionManager
Throws:
java.sql.SQLException

wrapperClosed

public void wrapperClosed(java.sql.Connection conn)
returns a Connection object to the ConnectionPool for reuse.


release

public void release()
releases all connections.


finalize

public void finalize()
Called by the JVM Garbage Collector: release all connections.


closeConnection

public void closeConnection(java.sql.Connection conn)
                     throws java.sql.SQLException
Throws:
java.sql.SQLException