org.apache.ojb.broker.accesslayer
Class ConnectionFactoryDBCPImpl

java.lang.Object
  extended by org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
      extended by org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl
All Implemented Interfaces:
ConnectionFactory

public class ConnectionFactoryDBCPImpl
extends ConnectionFactoryAbstractImpl

ConnectionFactory implementation using Commons DBCP and Commons Pool API to pool connections. Based on a proposal of Dirk Verbeek - Thanks.

Version:
$Id: ConnectionFactoryDBCPImpl.java 365045 2005-10-09 23:51:01Z arminw $
Author:
Armin Waibel
See Also:
Commons Pool Website, Commons DBCP Website

Field Summary
static java.lang.String PARAM_NAME_POOL_STATEMENTS
           
static java.lang.String PARAM_NAME_STATEMENT_POOL_MAX_TOTAL
           
static java.lang.String PARAM_NAME_UNWRAP_ALLOWED
           
 
Constructor Summary
ConnectionFactoryDBCPImpl()
           
 
Method Summary
 java.sql.Connection checkOutJdbcConnection(JdbcConnectionDescriptor jcd)
          Returns a valid JDBC Connection.
 void releaseAllResources()
          Closes all managed pools.
 void releaseJdbcConnection(JdbcConnectionDescriptor jcd, java.sql.Connection con)
          Releases a Connection after use.
 
Methods inherited from class org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl
lookupConnection, releaseConnection
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_NAME_UNWRAP_ALLOWED

public static final java.lang.String PARAM_NAME_UNWRAP_ALLOWED
See Also:
Constant Field Values

PARAM_NAME_POOL_STATEMENTS

public static final java.lang.String PARAM_NAME_POOL_STATEMENTS
See Also:
Constant Field Values

PARAM_NAME_STATEMENT_POOL_MAX_TOTAL

public static final java.lang.String PARAM_NAME_STATEMENT_POOL_MAX_TOTAL
See Also:
Constant Field Values
Constructor Detail

ConnectionFactoryDBCPImpl

public ConnectionFactoryDBCPImpl()
Method Detail

checkOutJdbcConnection

public java.sql.Connection checkOutJdbcConnection(JdbcConnectionDescriptor jcd)
                                           throws LookupException
Description copied from class: ConnectionFactoryAbstractImpl
Returns a valid JDBC Connection. Implement this method in concrete subclasses. Concrete implementations using Connection pooling are responsible for any validation and pool removal management.

Note: This method is never called for a jdbc-connection-descriptor that uses datasources, OJB only manages connections from DriverManager.

Note: If the concrete implementation does not callback to ConnectionFactoryAbstractImpl.newConnectionFromDriverManager(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor) when creating a new Connection, it must call ConnectionFactoryAbstractImpl.initializeJdbcConnection(java.sql.Connection, org.apache.ojb.broker.metadata.JdbcConnectionDescriptor) so that the platform implementation can peform any RDBMS-specific init tasks for newly created Connection objetcs.

Specified by:
checkOutJdbcConnection in class ConnectionFactoryAbstractImpl
Parameters:
jcd - the connection descriptor for which to return a validated Connection
Returns:
a valid Connection, never null. Specific implementations must guarantee that the connection is not null and that it is valid.
Throws:
LookupException - if a valid Connection could not be obtained

releaseJdbcConnection

public void releaseJdbcConnection(JdbcConnectionDescriptor jcd,
                                  java.sql.Connection con)
                           throws LookupException
Description copied from class: ConnectionFactoryAbstractImpl
Releases a Connection after use. Implement this method in concrete subclasses. Concrete implementations using Connection pooling are responsible for any validation and pool removal management.

Note: This method is never called for a jdbc-connection-descriptor that uses datasources, OJB only manages connections from DriverManager.

Specified by:
releaseJdbcConnection in class ConnectionFactoryAbstractImpl
Parameters:
jcd - the connection descriptor for which the connection was created
con - the connection to release. Callers must guarantee that the passed connection was obtained by calling ConnectionFactoryAbstractImpl.checkOutJdbcConnection(org.apache.ojb.broker.metadata.JdbcConnectionDescriptor).
Throws:
LookupException - if errors occured during release of object. Typically happens if return of object to pool fails in a pooled implementation.

releaseAllResources

public void releaseAllResources()
Closes all managed pools.

Specified by:
releaseAllResources in interface ConnectionFactory
Overrides:
releaseAllResources in class ConnectionFactoryAbstractImpl


(C) 2002 - 2006 Apache Software Foundation
All rights reserved. Published under the Apache License 2.0.
http://db.apache.org/ojb
Version: 1.0.4, 2005-12-30