sky.engine.connector.database
Class DBPool

java.lang.Object
  extended bysky.engine.connector.database.DBPool

public class DBPool
extends java.lang.Object

DBPool maintains and recycles open connections to the back-end database. These connections all allocated to forms as needed so that a new connection does not need to be created and destory everytime a form is invoked by the end-user.

$RCSfile: DBPool.java,v $
$Revision: 1.5 $, $Date: 2005/04/24 03:14:04 $


Field Summary
protected  DBConnection[] _cons
          Open connections in this connection pool.
protected  java.lang.String _jdrv
          JDBC driver name.
protected  java.lang.String _jurl
          JDBC URL over which this connection pool works.
protected  int _maxconn
          Maximum limit on number of connections in this pool.
protected  int _maxstmt
          Maximum limit on number of statements a connection can have.
protected  boolean[] _used
          flags to keep track of connections that are being currently used.
static FormattedResourceBundle STRINGS
           
 
Constructor Summary
DBPool(java.lang.String driver, java.lang.String url, int maxconn, int maxstmt)
          Constructor.
 
Method Summary
 DBConnection getConnection()
          Iterate through all the connections in this connection pool to locate a connection that is not being used.
 void returnConnection(DBConnection conn)
          Call this function after your done with using a connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_jdrv

protected java.lang.String _jdrv
JDBC driver name.


_jurl

protected java.lang.String _jurl
JDBC URL over which this connection pool works.


_cons

protected DBConnection[] _cons
Open connections in this connection pool.


_used

protected boolean[] _used
flags to keep track of connections that are being currently used.


_maxconn

protected int _maxconn
Maximum limit on number of connections in this pool.


_maxstmt

protected int _maxstmt
Maximum limit on number of statements a connection can have.


STRINGS

public static final FormattedResourceBundle STRINGS
Constructor Detail

DBPool

public DBPool(java.lang.String driver,
              java.lang.String url,
              int maxconn,
              int maxstmt)
Constructor.

Parameters:
driver - JDBC driver name.
url - JDBC URL.
maxconn - Maximum limit on the number of connections in this connection pool.
maxstmt - Maximum limit on the number of statements each connection can have.
Method Detail

getConnection

public DBConnection getConnection()
                           throws ErrorMessage
Iterate through all the connections in this connection pool to locate a connection that is not being used. If all the connections are being used, then create a new connection to return to the caller provided that the maximum limit on number of connections has not been reached.

Returns:
allocated database connection
Throws:
ErrorMessage - in case there are any problems.

returnConnection

public void returnConnection(DBConnection conn)
Call this function after your done with using a connection. This function will mark the connection as unused, clear on state information from the connection, and return it back to the connection pool.

Parameters:
conn - database connection that is currently being used.