public class DataSourceDbConnectionFactory extends Object implements DbConnectionFactory
DataSourceDbConnectionFactory class.
Constructor and Description |
---|
DataSourceDbConnectionFactory(DataSource dataSource)
Constructor for DataSourceDbConnectionFactory.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public DataSourceDbConnectionFactory(DataSource dataSource)
Constructor for DataSourceDbConnectionFactory.
dataSource
- a DataSource
object.public void destroy()
DbConnectionFactory
destroy
in interface DbConnectionFactory
public Connection getConnection() throws SQLException
DbConnectionFactory
getConnection
in interface DbConnectionFactory
Connection
object.SQLException
- if any.public void init(String dbUrl, String dbDriver, String username, String password) throws ClassNotFoundException
Only one init
method should be called.
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 usernameClassNotFoundException
- if any.public void releaseConnection(Connection connection) throws SQLException
releaseConnection
in interface DbConnectionFactory
connection
- the connection to releaseSQLException
- if any.Copyright © 2016. All rights reserved.