org.apache.jetspeed.components.datasource
Class DBCPDatasourceComponent

java.lang.Object
  extended by org.apache.jetspeed.components.datasource.DBCPDatasourceComponent
All Implemented Interfaces:
DatasourceComponent
Direct Known Subclasses:
BoundDBCPDatasourceComponent

public class DBCPDatasourceComponent
extends Object
implements DatasourceComponent

DBCPDatasourceComponent

Version:
$ $
Author:
Scott T. Weaver

Field Summary
private  String connectURI
           
protected  org.apache.commons.dbcp.PoolingDataSource dataSource
           
private  String driverName
           
private  org.apache.commons.dbcp.PoolableConnectionFactory dsConnectionFactory
           
private static org.apache.commons.logging.Log log
           
private  int maxActive
           
private  int maxWait
           
private  String password
           
private  String user
           
private  byte whenExhausted
           
 
Constructor Summary
DBCPDatasourceComponent(String user, String password, String driverName, String connectURI, int maxActive, int maxWait, byte whenExhausted, boolean autoCommit)
          Creates a simple commons DBCP connection pool using the following parameters.
 
Method Summary
 DataSource getDatasource()
           getDatasource
 void start()
           start
 void stop()
           stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

dataSource

protected org.apache.commons.dbcp.PoolingDataSource dataSource

user

private String user

password

private String password

driverName

private String driverName

connectURI

private String connectURI

maxActive

private int maxActive

maxWait

private int maxWait

whenExhausted

private byte whenExhausted

dsConnectionFactory

private org.apache.commons.dbcp.PoolableConnectionFactory dsConnectionFactory
Constructor Detail

DBCPDatasourceComponent

public DBCPDatasourceComponent(String user,
                               String password,
                               String driverName,
                               String connectURI,
                               int maxActive,
                               int maxWait,
                               byte whenExhausted,
                               boolean autoCommit)
Creates a simple commons DBCP connection pool using the following parameters.

If you need to bind the datasource of this component to JNDI please @see org.apache.jetspeed.components.jndi.JNDIComponent

Parameters:
user - User name that will be used to connect to the DB
password - Password that will be used to connect to the DB
driverName - Fully qualified driver to be used by the connection pool
connectURI - Fully qualified URI to the DB.
maxActive - Maximum active connection
maxWait - if whenExhausted is set to GenericObjectPool.WHEN_EXHAUSTED_BLOCK the length of time to block while waiting for a connection to become available.
whenExhausted - GenericObjectPool.WHEN_EXHAUSTED_BLOCK, GenericObjectPool.WHEN_EXHAUSTED_GROW or GenericObjectPool.WHEN_EXHAUSTED_FAIL. @see org.apache.commons.pooling.GenericObjectPool for more information on these settings
autoCommit - Whether or not this datasource will autocommit
Throws:
ClassNotFoundException - If the driverName could not be located within any classloaders.
Method Detail

getDatasource

public DataSource getDatasource()

getDatasource

returns the datasource created by this component

Specified by:
getDatasource in interface DatasourceComponent
Returns:

start

public void start()

start

See Also:
org.picocontainer.Startable#start()

stop

public void stop()

stop

See Also:
org.picocontainer.Startable#stop()


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.