Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lilacsoftware.orca.DBManager
Class DBConnectionManager.DBConnectionPool  view DBConnectionManager.DBConnectionPool download DBConnectionManager.DBConnectionPool.java

java.lang.Object
  extended bycom.lilacsoftware.orca.DBManager.DBConnectionManager.DBConnectionPool
Enclosing class:
DBConnectionManager

class DBConnectionManager.DBConnectionPool
extends java.lang.Object

This inner class represents a connection pool. It creates new connections on demand, up to a max number if specified. It also makes sure a connection is still open before it is returned to a client.


Field Summary
private  int checkedOut
           
private  java.util.Vector freeConnections
           
private  int maxConn
           
private  java.lang.String name
           
private  java.lang.String password
           
private  java.lang.String URL
           
private  java.lang.String user
           
 
Constructor Summary
protected DBConnectionManager.DBConnectionPool(java.lang.String name, java.lang.String URL, java.lang.String user, java.lang.String password, int maxConn)
          Creates new connection pool.
 
Method Summary
protected  void freeLocalConnection(java.sql.Connection con)
          Checks in a connection to the pool.
protected  java.sql.Connection getConnection()
          Checks out a connection from the pool.
protected  java.sql.Connection getConnection(long timeout)
          Checks out a connection from the pool.
private  java.sql.Connection newConnection()
          Creates a new connection, using a userid and password if specified.
protected  void release()
          Closes all available connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

checkedOut

private int checkedOut

freeConnections

private java.util.Vector freeConnections

maxConn

private int maxConn

name

private java.lang.String name

password

private java.lang.String password

URL

private java.lang.String URL

user

private java.lang.String user
Constructor Detail

DBConnectionManager.DBConnectionPool

protected DBConnectionManager.DBConnectionPool(java.lang.String name,
                                               java.lang.String URL,
                                               java.lang.String user,
                                               java.lang.String password,
                                               int maxConn)
Creates new connection pool.

Method Detail

freeLocalConnection

protected void freeLocalConnection(java.sql.Connection con)
Checks in a connection to the pool. Notify other Threads that may be waiting for a connection.


getConnection

protected java.sql.Connection getConnection()
Checks out a connection from the pool. If no free connection is available, a new connection is created unless the max number of connections has been reached. If a free connection has been closed by the database, it's removed from the pool and this method is called again recursively.


getConnection

protected java.sql.Connection getConnection(long timeout)
Checks out a connection from the pool. If no free connection is available, a new connection is created unless the max number of connections has been reached. If a free connection has been closed by the database, it's removed from the pool and this method is called again recursively.

If no connection is available and the max number has been reached, this method waits the specified time for one to be checked in.


release

protected void release()
Closes all available connections.


newConnection

private java.sql.Connection newConnection()
Creates a new connection, using a userid and password if specified.