|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.core.resource.db.SimpleDbConnectionFactory
A trivial implementation of DbConnectionFactory
that creates a
new connection for every request and does no caching or connection sharing.
Note that no real connection pooling is occurring within this class. This factory will be an inefficient connection management scheme for most real-world applications. It was designed only for development/debugging purposes and for applications that are very infrequently used. In those cases, caching idle database connections for long periods of time can be wasteful, and this pooling scheme would be appropriate.
This manager simply initializes the JDBC driver and then stores the database credential information (if any). Then when a connection is requested, a new connection is made with the stored credentials (if any).
Field Summary | |
protected java.lang.String |
password
|
protected java.util.Properties |
properties
|
protected java.lang.String |
url
|
protected java.lang.String |
username
|
Constructor Summary | |
SimpleDbConnectionFactory()
|
Method Summary | |
void |
destroy()
Clear all database URL and credential information so no more connections can be requested. |
java.sql.Connection |
getConnection()
Create a new connection for the given database URL. |
void |
init(java.lang.String dbUrl,
java.lang.String dbDriver)
Initialize a new database pool. |
void |
init(java.lang.String dbUrl,
java.lang.String dbDriver,
java.util.Properties properties)
Initialize a new database pool with the given database properties. |
void |
init(java.lang.String dbUrl,
java.lang.String dbDriver,
java.lang.String username,
java.lang.String password)
Initialize a new database pool with the given database username and password. |
void |
releaseConnection(java.sql.Connection connection)
Close the given connection. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String url
protected java.lang.String username
protected java.lang.String password
protected java.util.Properties properties
Constructor Detail |
public SimpleDbConnectionFactory()
Method Detail |
public void init(java.lang.String dbUrl, java.lang.String dbDriver) throws java.lang.ClassNotFoundException, java.sql.SQLException
init
in interface DbConnectionFactory
dbUrl
- the JDBC URL used to retrieve connectionsdbDriver
- a fully qualified class name for the JDBC driver that handles
this JDBC URL
java.lang.ClassNotFoundException
java.sql.SQLException
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
init
in interface DbConnectionFactory
dbUrl
- the JDBC URL used to retrieve connectionsdbDriver
- a fully qualified class name for the JDBC driver that will
handle this JDBC URLusername
- the name to use to authenticate us with the databasepassword
- the credentials use to authenticate the username
java.lang.ClassNotFoundException
java.sql.SQLException
public void init(java.lang.String dbUrl, java.lang.String dbDriver, java.util.Properties properties) throws java.lang.ClassNotFoundException, java.sql.SQLException
init
in interface DbConnectionFactory
dbUrl
- the JDBC URL used to retrieve connectionsdbDriver
- a fully qualified class name for the JDBC driver that will
handle this JDBC URLproperties
- a collection of database properties, these may be specific to
your particular database
java.lang.ClassNotFoundException
java.sql.SQLException
public void destroy()
destroy
in interface DbConnectionFactory
public java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface DbConnectionFactory
java.sql.SQLException
public void releaseConnection(java.sql.Connection connection) throws java.sql.SQLException
releaseConnection
in interface DbConnectionFactory
connection
- the connection to release
java.sql.SQLException
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |