com.neoworks.connectionpool
Class PoolManager

java.lang.Object
  |
  +--com.neoworks.connectionpool.PoolManager

public class PoolManager
extends java.lang.Object

Connection pool manager.


Method Summary
static void configure(org.w3c.dom.Element config)
          Configure the PoolManager from a DOM Element
static void configure(org.w3c.dom.Element config, java.lang.String xpath)
          Configure the PoolManager from a DOM Element, using a specific XPath query
 java.sql.Connection getConnection(java.lang.String name)
          Return a connection from the pool identified by the given string.
static PoolManager getInstance()
          Return the static instance of this class.
 void loadConfig(org.w3c.dom.Element configroot)
          Initialise the database pool with the XML node passed, which should be of the form:
 void loadConfig(java.io.InputStream is)
          Configures the instance by reading properties from a given input stream, instantiating drivers and connection pools.
 void release()
          Clean up resources used by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PoolManager getInstance()
Return the static instance of this class.

Returns:
The single instance of this class, or null if there was a problem reading the properties file, setting up the connection pools and registering drives..

configure

public static void configure(org.w3c.dom.Element config)
Configure the PoolManager from a DOM Element

Parameters:
config - The DOM Element to configure from

configure

public static void configure(org.w3c.dom.Element config,
                             java.lang.String xpath)
Configure the PoolManager from a DOM Element, using a specific XPath query

Parameters:
config - The DOM Element to configure from
xpath - The XPath query to use

loadConfig

public void loadConfig(org.w3c.dom.Element configroot)
Initialise the database pool with the XML node passed, which should be of the form:
 <databasepool>
     <driver classname="org.mydriver.whatever" />
     ...

     <pool
     name="poolname"
     url="jdbc url of database"
     user="username to connect to database"
     password=""
     maxconns="maximum connections to reach"
     initconns="initial connections to open"
     logintimeout="timeout for login to database"
     />
     ...

 </databasepool>
 
 


loadConfig

public void loadConfig(java.io.InputStream is)
                throws java.io.IOException,
                       java.lang.ClassNotFoundException,
                       java.lang.InstantiationException,
                       java.lang.IllegalAccessException,
                       java.sql.SQLException
Configures the instance by reading properties from a given input stream, instantiating drivers and connection pools.

Ensure that any resources that are currently allocated are cleaned up, re-read the properties file, register drivers and set up connection pools.

Parameters:
is - The InputStream to load the properties from.
Throws:
java.io.IOException - If there was a problem loading the properties from the specified InputStream.
java.lang.ClassNotFoundException - If there was a problem loading one of the driver classes.
java.lang.InstantiationException - If there was a problem instantiating one of the drivers.
java.lang.IllegalAccessException - If there was a problem accessing the class file of one of the drivers.
java.sql.SQLException - If there was a problem registering a driver.

release

public void release()
             throws java.sql.SQLException
Clean up resources used by this class.

Throws:
java.sql.SQLException - If there was a problem deregistering one of the drivers.

getConnection

public java.sql.Connection getConnection(java.lang.String name)
                                  throws java.sql.SQLException
Return a connection from the pool identified by the given string.

Parameters:
name - The string identifier of the connection pool from which we want the connection.
Returns:
A connection from the appropriate pool.
java.sql.SQLException