fc.jdbc
Class PooledConnectionMgr

java.lang.Object
  extended by fc.jdbc.ConnectionMgr
      extended by fc.jdbc.PooledConnectionMgr

public class PooledConnectionMgr
extends ConnectionMgr

A pooled connection manager. Connections must be closed when done with, which automatically returns them back to the pool.


Field Summary
static long ConnectionTimeoutWarning
          If a connection cannot be obtained within this time, then a warning will be logged.
static int defaultSize
           
 
Constructor Summary
PooledConnectionMgr(PropertyMgr props, int size)
          Constructs a new connection pool with the specified size.
PooledConnectionMgr(PropertyMgr props, String prefix, int size)
          Constructs a new connection pool with the specified size.
PooledConnectionMgr(String jdbc_url, String jdbc_driver, String jdbc_user, String jdbc_password, String jdbc_catalog, int size)
          Constructs a new connection pool with the specified size.
PooledConnectionMgr(SystemLog log, PropertyMgr props, int size)
          Constructs a new connection pool with the specified size.
PooledConnectionMgr(SystemLog log, PropertyMgr props, String prefix, int size)
          Constructs a new connection pool with the specified size.
 
Method Summary
 Iterator getCheckoutInfo()
          Returns a iterator over a collection of Exception objects, each containing a stack trace for code that has currently checked out a connection from this pool.
 List getHungTransactions(long milliseconds)
          Gets a list of connections in the pool such that each connection has a transaction that was started more than the specified milliseconds ago but has not yet been aborted or commited (this is a good way to see if there is a transaction leak somewhere).
static void main(String[] args)
           
 void setDebugCheckout(boolean dbg)
          Helps to debug connection checkouts.
 String toString()
           
 
Methods inherited from class fc.jdbc.ConnectionMgr
close, getConnection, getDBName, getDriver, getURL, setCatalog
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultSize

public static final int defaultSize
See Also:
Constant Field Values

ConnectionTimeoutWarning

public static final long ConnectionTimeoutWarning
If a connection cannot be obtained within this time, then a warning will be logged. The value is in milliseconds.

See Also:
Constant Field Values
Constructor Detail

PooledConnectionMgr

public PooledConnectionMgr(String jdbc_url,
                           String jdbc_driver,
                           String jdbc_user,
                           String jdbc_password,
                           String jdbc_catalog,
                           int size)
                    throws Exception
Constructs a new connection pool with the specified size. ConnectionMgr

Throws:
Exception

PooledConnectionMgr

public PooledConnectionMgr(PropertyMgr props,
                           int size)
                    throws Exception
Constructs a new connection pool with the specified size. The size is the number of connections that this pool holds.

Throws:
Exception

PooledConnectionMgr

public PooledConnectionMgr(PropertyMgr props,
                           String prefix,
                           int size)
                    throws Exception
Constructs a new connection pool with the specified size. The size is the number of connections that this pool holds.

Throws:
Exception

PooledConnectionMgr

public PooledConnectionMgr(SystemLog log,
                           PropertyMgr props,
                           int size)
                    throws Exception
Constructs a new connection pool with the specified size. The size is the number of connections that this pool holds.

Throws:
Exception

PooledConnectionMgr

public PooledConnectionMgr(SystemLog log,
                           PropertyMgr props,
                           String prefix,
                           int size)
                    throws Exception
Constructs a new connection pool with the specified size. The size is the number of connections that this pool holds.

Throws:
Exception
Method Detail

setDebugCheckout

public void setDebugCheckout(boolean dbg)
Helps to debug connection checkouts. By default, this is false (since there is a stack trace overhead per connection when debugging is enabled).

Parameters:
dbg - true to enable tracking of checked out connections from this pool. false stops tracking and clears any existing tracking info.

getCheckoutInfo

public Iterator getCheckoutInfo()
Returns a iterator over a collection of Exception objects, each containing a stack trace for code that has currently checked out a connection from this pool. For this to work, make sure that setDebugCheckout(boolean) has first been invoked with true.


getHungTransactions

public List getHungTransactions(long milliseconds)
Gets a list of connections in the pool such that each connection has a transaction that was started more than the specified milliseconds ago but has not yet been aborted or commited (this is a good way to see if there is a transaction leak somewhere).


toString

public String toString()
Overrides:
toString in class ConnectionMgr

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception