com.ca.jcs.jdbc
Class JDBCConnectionManager

java.lang.Object
  extended by com.ca.jcs.jdbc.JDBCConnectionManager
All Implemented Interfaces:
Activatable, ConnectionManager

public class JDBCConnectionManager
extends Object
implements ConnectionManager

Simplistic connection manager wrapping a datasource and returning Connections. Not expected to to be used universally as clients making use of higher level APIs like Spring may well choose to use the non-standard connector.getDataSource() instead of dealing with SQL connections explicitly.

Note that any SQL exceptions thrown are wrapped and converted to Spring exceptions so they can be mapped to NamingExceptions in a consistent way by JDBCExceptionMappingProxy.


Constructor Summary
JDBCConnectionManager(DataSource dataSource)
           
 
Method Summary
 void activate()
          Derived classes should override if required, is a stub in this class.
 Object borrowConnection()
          Needs to be abstract for force implementers to very carefully review any exceptions that might be thrown and decide which ones are retriable soft failures (in which case should throw LdapServiceUnavailableException with code ResultCodeEnum.UNAVAILABLE) and which ones are hard failures (in which can throw LdapServiceUnavailableException with any other code, or any other NamingException variety which implements LdapException).
 void clearConnection()
          This method can be called to clear all existing connections in the pool when one is found to be in a in stale or inconsistent state.
 void deactivate()
          Derived classes should override if required, is a stub in this class.
 void returnConnection(Object connection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCConnectionManager

public JDBCConnectionManager(DataSource dataSource)
Method Detail

borrowConnection

public Object borrowConnection()
                        throws NamingException
Description copied from interface: ConnectionManager
Needs to be abstract for force implementers to very carefully review any exceptions that might be thrown and decide which ones are retriable soft failures (in which case should throw LdapServiceUnavailableException with code ResultCodeEnum.UNAVAILABLE) and which ones are hard failures (in which can throw LdapServiceUnavailableException with any other code, or any other NamingException variety which implements LdapException).

Specified by:
borrowConnection in interface ConnectionManager
Returns:
Non-null live connection.
Throws:
NamingException - If connection can't be borrowed, can't return null.

returnConnection

public void returnConnection(Object connection)
Specified by:
returnConnection in interface ConnectionManager

activate

public void activate()
              throws NamingException
Derived classes should override if required, is a stub in this class.

Specified by:
activate in interface Activatable
Throws:
NamingException

deactivate

public void deactivate()
                throws NamingException
Derived classes should override if required, is a stub in this class.

Specified by:
deactivate in interface Activatable
Throws:
NamingException

clearConnection

public void clearConnection()
                     throws NamingException
Description copied from interface: ConnectionManager
This method can be called to clear all existing connections in the pool when one is found to be in a in stale or inconsistent state. See RetryOpProcessorProxy for an example.

Specified by:
clearConnection in interface ConnectionManager
Throws:
NamingException


Created 2011-07-14 13:27 EST