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.
-
freeConnection(String, Connection)
- Returns a connection to the named pool.
-
getConnection(String)
- Returns an open connection.
-
getConnection(String, long)
- Returns an open connection.
-
getDatabaseName()
- get the database name
-
getInstance()
- Returns the single instance, creating one if it's the
first time this method is called.
-
getPoolNames()
- get the pool names
-
getUploadDir()
- get the upload directory
-
release()
- Closes all open connections and deregisters all drivers.
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.
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
getPoolNames
public Enumeration getPoolNames()
- get the pool names
getUploadDir
public String getUploadDir()
- get the upload directory
getDatabaseName
public String getDatabaseName()
- get the database name
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
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
release
public synchronized void release()
- Closes all open connections and deregisters all drivers.
All Packages Class Hierarchy This Package Previous Next Index