org.apache.avalon.excalibur.datasource
Class JdbcDataSource

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.excalibur.datasource.JdbcDataSource
All Implemented Interfaces:
Component, Configurable, DataSourceComponent, Disposable, LogEnabled, ThreadSafe

public class JdbcDataSource
extends AbstractLogEnabled
implements DataSourceComponent, Disposable

The Default implementation for DataSources in Avalon. This uses the normal java.sql.Connection object and java.sql.DriverManager.

Configuration Example:

   <jdbc>
     <pool-controller min="5" max="10" connection-class="my.overrided.ConnectionClass">
       <keep-alive disable="false" age="5000">select 1</keep-alive>
     </pool-controller>
     <auto-commit>true</auto-commit>
     <driver>com.database.jdbc.JdbcDriver</driver>
     <dburl>jdbc:driver://host/mydb</dburl>
     <user>username</user>
     <password>password</password>
   </jdbc>
 

Configuration Attributes:

Since:
4.0
Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:14 $
Author:
Avalon Development Team

Field Summary
protected  JdbcConnectionPool m_pool
           
 
Fields inherited from interface org.apache.avalon.excalibur.datasource.DataSourceComponent
ROLE
 
Constructor Summary
JdbcDataSource()
           
 
Method Summary
 void configure(Configuration configuration)
          Configure and set up DB connection.
 void dispose()
          Dispose properly of the pool
 java.sql.Connection getConnection()
          Get the database connection
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_pool

protected JdbcConnectionPool m_pool
Constructor Detail

JdbcDataSource

public JdbcDataSource()
Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Configure and set up DB connection. Here we set the connection information needed to create the Connection objects. It must be called only once.

Specified by:
configure in interface Configurable
Parameters:
configuration - the class configurations. Must not be null.
Throws:
ConfigurationException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Get the database connection

Specified by:
getConnection in interface DataSourceComponent
Returns:
Connection a valid connection for you to use
Throws:
java.sql.SQLException

dispose

public void dispose()
Dispose properly of the pool

Specified by:
dispose in interface Disposable


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.