net.sf.colle.sql
Class ConnectionManager

java.lang.Object
  extended bynet.sf.colle.sql.ConnectionManager

public class ConnectionManager
extends Object

Gets and releases connections to a JDBC datasource. Created: 23 Apr 2001

Version:
$Revision: 1.9 $, $Date: 2004/09/13 05:01:39 $
Author:
Dwayne Schultz

Nested Class Summary
static class ConnectionManager.Configuration
           
 
Method Summary
static Connection getConnection()
          Gets a new database connection.
static Connection getConnection(ConnectionManager.Configuration pxConfig)
           
static Connection getConnection(String psDatabase)
          Gets a new database connection.
static boolean getDebug()
           
static List getOpenConnectionsStackTraces()
          Returns a list of strings containing stack traces identifying the code that allocated each of the outstanding database connections.
static List getOpenConnectionsStackTraces(ConnectionManager.Configuration pxConfig)
           
static void releaseConnection(Connection pxConnection)
          Releases a database connection after it's use.
static void releaseConnection(Connection pxConnection, ConnectionManager.Configuration pxConfig)
           
static void setDebug(boolean pbDebug)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConnection

public static Connection getConnection()
Gets a new database connection. releaseConnection must always be called when the caller is done using the connection. This version will connect to the default database defined by the following system properties: net.sf.colle.sql.ConnectionManager.jndi JNDI name of the database. This must be defined and/or driver and databaseURL must be defined. net.sf.colle.sql.ConnectionManager.driver Name of the JDBC driver class. This and databaseURL must be defined and/or jndi must be defined. net.sf.colle.sql.ConnectionManager.databaseURL JDBC driver specific URL to locate the database. This and driver must be defined and/or jndi must be defined. net.sf.colle.sql.ConnectionManager.username Username used to connect to the database. net.sf.colle.sql.ConnectionManager.password Password used to connect to the database. net.sf.colle.sql.ConnectionManager.logging If set to true, Connection manager will keep a collection of stack traces for each call to getConnection without a corresponding call to releaseConnection. The application can then call getOpenConnectionsStackTraces to see where connections are being leaked.


getConnection

public static Connection getConnection(String psDatabase)
Gets a new database connection. releaseConnection must always be called when the caller is done using the connection. This version accepts the database to connect to. This should be used as a prefix to the system properties used to define the connection.


getConnection

public static Connection getConnection(ConnectionManager.Configuration pxConfig)

releaseConnection

public static void releaseConnection(Connection pxConnection)
Releases a database connection after it's use.


releaseConnection

public static void releaseConnection(Connection pxConnection,
                                     ConnectionManager.Configuration pxConfig)

getOpenConnectionsStackTraces

public static List getOpenConnectionsStackTraces()
Returns a list of strings containing stack traces identifying the code that allocated each of the outstanding database connections. This feature is turned on by defining the "net.sf.colle.sql.ConnectionManager.logging" system property.


getOpenConnectionsStackTraces

public static List getOpenConnectionsStackTraces(ConnectionManager.Configuration pxConfig)

getDebug

public static boolean getDebug()

setDebug

public static void setDebug(boolean pbDebug)