org.opensolaris.opengrok.jdbc
Class ConnectionManager

java.lang.Object
  extended by org.opensolaris.opengrok.jdbc.ConnectionManager

public class ConnectionManager
extends java.lang.Object

Class that manages the pool of database connections.


Constructor Summary
ConnectionManager(java.lang.String driverClass, java.lang.String url)
          Create a new ConnectionManager instance.
 
Method Summary
 ConnectionResource getConnectionResource()
          Get a ConnectionResource object from the pool, or create a new one if the pool is empty.
 void releaseConnection(ConnectionResource cr)
          Return a ConnectionResource back to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

public ConnectionManager(java.lang.String driverClass,
                         java.lang.String url)
                  throws java.lang.ClassNotFoundException
Create a new ConnectionManager instance.

Parameters:
driverClass - the name of the JDBC driver class
url - the JDBC connection URL to the database
Throws:
java.lang.ClassNotFoundException - if the JDBC driver class cannot be found
Method Detail

getConnectionResource

public ConnectionResource getConnectionResource()
                                         throws java.sql.SQLException
Get a ConnectionResource object from the pool, or create a new one if the pool is empty. Callers should make sure that the object is returned to the pool by calling releaseConnection(ConnectionResource) after they are finished with it.

Returns:
a ConnectionResource object
Throws:
java.sql.SQLException - if a database error occurs

releaseConnection

public void releaseConnection(ConnectionResource cr)
                       throws java.sql.SQLException
Return a ConnectionResource back to the pool.

Parameters:
cr -
Throws:
java.sql.SQLException