org.opennms.core.resource.db
Class DataSourceDbConnectionFactory

java.lang.Object
  extended by org.opennms.core.resource.db.DataSourceDbConnectionFactory
All Implemented Interfaces:
DbConnectionFactory

public class DataSourceDbConnectionFactory
extends Object
implements DbConnectionFactory

Author:
DJ Gregor

Constructor Summary
DataSourceDbConnectionFactory(DataSource dataSource)
           
 
Method Summary
 void destroy()
          Deallocate all the resources that may have been allocated to this database connection factory.
 Connection getConnection()
          Retrieve a connection from the given database connection pool.
 void init(String dbUrl, String dbDriver, String username, String password)
          Initialize a database factory with the given URL, driver classname, and database credentials.
 void releaseConnection(Connection connection)
          Replace a database connection back in the pool of available connections for its parent pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceDbConnectionFactory

public DataSourceDbConnectionFactory(DataSource dataSource)
Method Detail

destroy

public void destroy()
             throws SQLException
Description copied from interface: DbConnectionFactory
Deallocate all the resources that may have been allocated to this database connection factory. Makes this factory unavailable for new connection requests.

Specified by:
destroy in interface DbConnectionFactory
Throws:
SQLException

getConnection

public Connection getConnection()
                         throws SQLException
Description copied from interface: DbConnectionFactory
Retrieve a connection from the given database connection pool.

Specified by:
getConnection in interface DbConnectionFactory
Throws:
SQLException

init

public void init(String dbUrl,
                 String dbDriver,
                 String username,
                 String password)
          throws ClassNotFoundException,
                 SQLException
Description copied from interface: DbConnectionFactory
Initialize a database factory with the given URL, driver classname, and database credentials. Will guarantee that the JDBC driver is loaded and that connections will be available.

Only one init method should be called.

Specified by:
init in interface DbConnectionFactory
Parameters:
dbUrl - the JDBC URL used to retrieve connections
dbDriver - a fully qualified class name for the JDBC driver that will handle this JDBC URL
username - the name to use to authenticate us with the database
password - the credentials use to authenticate the username
Throws:
ClassNotFoundException
SQLException

releaseConnection

public void releaseConnection(Connection connection)
                       throws SQLException
Description copied from interface: DbConnectionFactory
Replace a database connection back in the pool of available connections for its parent pool.

Specified by:
releaseConnection in interface DbConnectionFactory
Parameters:
connection - the connection to release
Throws:
SQLException


Copyright © 2009. All Rights Reserved.