dbpool
Class DBConnectionMgr

java.lang.Object
  extended bydbpool.DBConnectionMgr

public class DBConnectionMgr
extends java.lang.Object

Manages a java.sql.Connection pool.

Author:
Anil Hemrajani

Constructor Summary
DBConnectionMgr()
           
 
Method Summary
 void finalize()
          Closes all connections and clears out the connection pool
 void freeConnection(java.sql.Connection c)
          Marks a flag in the ConnectionObject to indicate this connection is no longer in use
 void freeConnection(java.sql.Connection c, java.sql.PreparedStatement p)
           
 void freeConnection(java.sql.Connection c, java.sql.PreparedStatement p, java.sql.ResultSet r)
           
 void freeConnection(java.sql.Connection c, java.sql.Statement s)
           
 void freeConnection(java.sql.Connection c, java.sql.Statement s, java.sql.ResultSet r)
           
 java.sql.Connection getConnection()
          Returns an unused existing or new connection.
 int getConnectionCount()
          Returns a count of open connections
 java.util.Vector getConnectionList()
          Returns a Vector of java.sql.Connection objects
static DBConnectionMgr getInstance()
          Use this method to set the maximum number of open connections before unused connections are closed.
 void releaseFreeConnections()
          Closes all connections and clears out the connection pool
 void removeConnection(java.sql.Connection c)
          Marks a flag in the ConnectionObject to indicate this connection is no longer in use
 void setEnableTrace(boolean enable)
           
 void setInitOpenConnections(int count)
          Opens specified "count" of connections and adds them to the existing pool
 void setOpenConnectionCount(int count)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBConnectionMgr

public DBConnectionMgr()
Method Detail

getInstance

public static DBConnectionMgr getInstance()
Use this method to set the maximum number of open connections before unused connections are closed.


setOpenConnectionCount

public void setOpenConnectionCount(int count)

setEnableTrace

public void setEnableTrace(boolean enable)

getConnectionList

public java.util.Vector getConnectionList()
Returns a Vector of java.sql.Connection objects


setInitOpenConnections

public void setInitOpenConnections(int count)
                            throws java.sql.SQLException
Opens specified "count" of connections and adds them to the existing pool

Throws:
java.sql.SQLException

getConnectionCount

public int getConnectionCount()
Returns a count of open connections


getConnection

public java.sql.Connection getConnection()
                                  throws java.lang.Exception
Returns an unused existing or new connection.

Throws:
java.lang.Exception

freeConnection

public void freeConnection(java.sql.Connection c)
Marks a flag in the ConnectionObject to indicate this connection is no longer in use


freeConnection

public void freeConnection(java.sql.Connection c,
                           java.sql.PreparedStatement p,
                           java.sql.ResultSet r)

freeConnection

public void freeConnection(java.sql.Connection c,
                           java.sql.Statement s,
                           java.sql.ResultSet r)

freeConnection

public void freeConnection(java.sql.Connection c,
                           java.sql.PreparedStatement p)

freeConnection

public void freeConnection(java.sql.Connection c,
                           java.sql.Statement s)

removeConnection

public void removeConnection(java.sql.Connection c)
Marks a flag in the ConnectionObject to indicate this connection is no longer in use


releaseFreeConnections

public void releaseFreeConnections()
Closes all connections and clears out the connection pool


finalize

public void finalize()
Closes all connections and clears out the connection pool