All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.paneris.util.DBConnectionManager

java.lang.Object
   |
   +----org.paneris.util.DBConnectionManager

public class DBConnectionManager
extends Object
This class is a Singleton that provides access to one or many connection pools defined in a Property file. A client gets access to the single instance through the static getInstance() method and can then check-out and check-in connections from a pool. When the client shuts down it should call the release() method to close all open connections and do other clean up.


Method Index

 o freeConnection(String, Connection)
Returns a connection to the named pool.
 o getConnection(String)
Returns an open connection.
 o getConnection(String, long)
Returns an open connection.
 o getDatabaseName()
get the database name
 o getInstance()
Returns the single instance, creating one if it's the first time this method is called.
 o getPoolNames()
get the pool names
 o getUploadDir()
get the upload directory
 o release()
Closes all open connections and deregisters all drivers.

Methods

 o getInstance
 public static synchronized DBConnectionManager getInstance()
Returns the single instance, creating one if it's the first time this method is called.

Returns:
DBConnectionManager The single instance.
 o freeConnection
 public void freeConnection(String name,
                            Connection con)
Returns a connection to the named pool.

Parameters:
name - The pool name as defined in the properties file
con - The Connection
 o getPoolNames
 public Enumeration getPoolNames()
get the pool names

 o getUploadDir
 public String getUploadDir()
get the upload directory

 o getDatabaseName
 public String getDatabaseName()
get the database name

 o getConnection
 public Connection getConnection(String name)
Returns an open connection. If no one is available, and the max number of connections has not been reached, a new connection is created.

Parameters:
name - The pool name as defined in the properties file
Returns:
Connection The connection or null
 o getConnection
 public Connection getConnection(String name,
                                 long time)
Returns an open connection. If no one is available, and the max number of connections has not been reached, a new connection is created. If the max number has been reached, waits until one is available or the specified time has elapsed.

Parameters:
name - The pool name as defined in the properties file
time - The number of milliseconds to wait
Returns:
Connection The connection or null
 o release
 public synchronized void release()
Closes all open connections and deregisters all drivers.


All Packages  Class Hierarchy  This Package  Previous  Next  Index