OpenNMS API 1.2.3

org.opennms.core.resource.db
Interface DbConnectionFactory

All Known Implementing Classes:
SimpleDbConnectionFactory

public interface DbConnectionFactory

A DbConnectionFactory allocates and deallocates connections from a database. The concrete implementations of this interface specify a particular allocation/deallocation policy.

For example, an implementation might use and reuse connections from a persistent pool of connections, while another might dynamically allocate and deallocate connections for each request.

Author:
Lawrence Karnowski , OpenNMS

Method Summary
 void destroy()
          Deallocate all the resources that may have been allocated to this database connection factory.
 java.sql.Connection getConnection()
          Retrieve a connection from the given database connection pool.
 void init(java.lang.String dbUrl, java.lang.String dbDriver)
          Initialize a database factory with the given URL and driver classname.
 void init(java.lang.String dbUrl, java.lang.String dbDriver, java.util.Properties properties)
          Initialize a database factory with the given URL, driver classname, and database properties.
 void init(java.lang.String dbUrl, java.lang.String dbDriver, java.lang.String username, java.lang.String password)
          Initialize a database factory with the given URL, driver classname, and database credentials.
 void releaseConnection(java.sql.Connection connection)
          Replace a database connection back in the pool of available connections for its parent pool.
 

Method Detail

init

public void init(java.lang.String dbUrl,
                 java.lang.String dbDriver)
          throws java.lang.ClassNotFoundException,
                 java.sql.SQLException
Initialize a database factory with the given URL and driver classname. Will guarantee that the JDBC driver is loaded and that connections will now be available.

Only one init method should be called.

Parameters:
dbUrl - the JDBC URL used to retrieve connections
dbDriver - a fully qualified class name for the JDBC driver that handles this JDBC URL
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

init

public void init(java.lang.String dbUrl,
                 java.lang.String dbDriver,
                 java.lang.String username,
                 java.lang.String password)
          throws java.lang.ClassNotFoundException,
                 java.sql.SQLException
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.

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:
java.lang.ClassNotFoundException
java.sql.SQLException

init

public void init(java.lang.String dbUrl,
                 java.lang.String dbDriver,
                 java.util.Properties properties)
          throws java.lang.ClassNotFoundException,
                 java.sql.SQLException
Initialize a database factory with the given URL, driver classname, and database properties. Will guarantee that the JDBC driver is loaded and that connections will be available.

Only one init method should be called.

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
properties - a collection of database properties, these may be specific to your particular database
Throws:
java.lang.ClassNotFoundException
java.sql.SQLException

destroy

public void destroy()
             throws java.sql.SQLException
Deallocate all the resources that may have been allocated to this database connection factory. Makes this factory unavailable for new connection requests.

Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Retrieve a connection from the given database connection pool.

Throws:
java.lang.IllegalStateException - If the factory has not been initialized or has been destroyed.
java.sql.SQLException

releaseConnection

public void releaseConnection(java.sql.Connection connection)
                       throws java.sql.SQLException
Replace a database connection back in the pool of available connections for its parent pool.

Parameters:
connection - the connection to release
Throws:
java.lang.IllegalStateException - If the factory has not been initialized or has been destroyed.
java.sql.SQLException

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.