public class JDBCResourceFactory extends ResourceFactory
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
databaseName_ |
private java.lang.String |
password_ |
private java.lang.String |
userName_ |
| Constructor and Description |
|---|
JDBCResourceFactory(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
Create the factory.
|
JDBCResourceFactory(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password,
boolean verifyThatConnectionCanBeOpened)
Create the factory.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.sql.Connection |
allocateRealConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
Allocate a real database connection from the DriverManager
|
private void |
ensureDatabaseCanBeOpened() |
protected void |
freeRealConnection(java.sql.Connection connection)
Free a real database connection
|
protected ManagedResource |
getResourceImpl(ResourceManager resourceManager)
Allocate a resource for the specified store
|
boolean |
reinitializeResourceIfPossible(ManagedResource resource)
Reinitialize the resource to a known state.
|
protected void |
releaseResourceImpl(ResourceManager resourceManager,
ManagedResource resource)
Release the specified resource.
|
getResource, releaseAllResources, releaseResourceprivate final java.lang.String databaseName_
private final java.lang.String userName_
private final java.lang.String password_
public JDBCResourceFactory(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
throws java.sql.SQLException
databaseName - The name of the databaseuserName - The user id that we will use to connect to the databasepassword - The password for the specified userjava.sql.SQLException - If an error occurspublic JDBCResourceFactory(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password,
boolean verifyThatConnectionCanBeOpened)
throws java.sql.SQLException
databaseName - The name of the databaseuserName - The user id that we will use to connect to the databasepassword - The password for the specified userverifyThatConnectionCanBeOpened - If true than one connection will
be immediately allocated and then freed from the specified databasejava.sql.SQLException - If an error occurspublic boolean reinitializeResourceIfPossible(ManagedResource resource)
reinitializeResourceIfPossible in class ResourceFactoryresource - the resource to reinitializeprotected ManagedResource getResourceImpl(ResourceManager resourceManager) throws java.lang.Exception
getResourceImpl in class ResourceFactoryresourceManager - The resource manager that owns this factoryjava.lang.Exception - If an error occursprotected void releaseResourceImpl(ResourceManager resourceManager, ManagedResource resource) throws java.lang.Exception
releaseResourceImpl in class ResourceFactoryresource - The resource that we are releasingresourceManager - The manager that is controlling this factoryjava.lang.Exception - If an error occursprotected final java.sql.Connection allocateRealConnection(java.lang.String databaseName,
java.lang.String userName,
java.lang.String password)
throws java.sql.SQLException
databaseName - The name of the databaseuserName - The user id that we will use to connect to the databasepassword - The password for the specified userjava.sql.SQLException - If an error occursprotected final void freeRealConnection(java.sql.Connection connection)
throws java.sql.SQLException
connection - The connection to releasejava.sql.SQLException - If an error occursprivate void ensureDatabaseCanBeOpened()
throws java.sql.SQLException
java.sql.SQLException