|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface DatabaseConnectionFactory
Interface to encapsulate retrieving and returning of database connections. Data connection factory is here to implement the Abstract Factory pattern as described in http://homepage.mac.com/loeffler/java/patterns/absfac.html by GoF95 http://homepage.mac.com/loeffler/java/patterns.html. The main reason is that database connections can be managed in different ways: they may be always opened when requested or pooled and retrieved from the pool, they might be created by the driver or retrieved from the data source. This interface provides unified way how to access the database connection regardless of implementation.
| Method Summary | |
|---|---|
void |
addDataSource(java.lang.String strDataSourceName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
Create new data source. |
java.lang.String |
debug()
Create string representing state of the factory so we can user it to debug connection related problems. |
java.lang.String |
getDatabaseAdminPassword()
Returns the database administration password. |
java.lang.String |
getDatabaseAdminUser()
Returns the database administration user. |
java.lang.String |
getDatabaseDriver()
Returns the database driver identification. |
java.lang.String |
getDatabasePassword()
Returns the database password. |
java.lang.String |
getDatabaseURL()
Returns the database URL. |
java.lang.String |
getDatabaseUser()
Returns the database user. |
java.lang.String |
getDefaultDataSourceName()
Get the name of the default data source. |
java.lang.String |
getRealDatabaseDriver()
Get real driver name which is used to connect to database. |
int |
getRequestedConnectionCount()
Get number for connections which are currently requested and were not returned for default data source. |
int |
getRequestedConnectionCount(java.lang.String strDataSourceName)
Get number for connections which are currently requested and were not returned. |
int |
getTotalRequestedConnectionCount()
Get total number for connections (for all data sources) which are currently requested and were not returned. |
boolean |
getUseAdminDataSource()
Get the flag specifying if to use separate datasource instead just different creadentials to obtain administrator connection. |
boolean |
isDataSourceDefined(java.lang.String strDataSourceName)
Check if the specified data has been already defined |
void |
loadDefaultDatabaseProperties()
Load default database properties such as what driver, user name or password to use from configuration file. |
java.sql.Connection |
requestConnection(boolean bAutoCommit)
Get connection to a database as configured by the default data source. |
java.sql.Connection |
requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
Get connection to a database as configured by the default data source. |
java.sql.Connection |
requestConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
Get connection to a database as configured by the default data source but using explicit user credential. |
java.sql.Connection |
requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
Get connection to a database as configured by the default data source but using explicit user credential. |
void |
returnConnection(java.sql.Connection cntDBConnection)
Release connection to a database. |
void |
setDatabaseAdminPassword(java.lang.String strDatabasePassword)
Sets the database administration password. |
void |
setDatabaseAdminUser(java.lang.String strDatabaseUser)
Sets the database administration user. |
void |
setDatabaseDriver(java.lang.String strDatabaseDriver)
Sets the database driver identification. |
void |
setDatabasePassword(java.lang.String strDatabasePassword)
Sets the database password. |
void |
setDatabaseURL(java.lang.String strDatabaseURL)
Sets the database URL. |
void |
setDatabaseUser(java.lang.String strDatabaseUser)
Sets the database user. |
void |
setDefaultDataSourceName(java.lang.String strDataSourceName)
Set the default data source. |
void |
setUseAdminDataSource(boolean bUseAdminDataSource)
Sets the flag specifying if to use separate datasource instead just different creadentials to obtain administrator connection. |
void |
stop()
Stop the connection factory. |
| Method Detail |
|---|
java.sql.Connection requestConnection(boolean bAutoCommit)
throws OSSDatabaseAccessException
bAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.
OSSDatabaseAccessException - - if connection cannot be establishedreturnConnection(java.sql.Connection)
java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
bAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strUser - - user name to connect to the databasestrPassword - - password to the database
OSSDatabaseAccessException - - if connection cannot be establishedreturnConnection(java.sql.Connection)
java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
throws OSSDatabaseAccessException
bAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strDataSourceName - - data source which will be used to get connections
OSSDatabaseAccessException - - if connection cannot be establishedreturnConnection(java.sql.Connection)
java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
bAutoCommit - - The desired autocommit state of the connection. If
this connection is invoked in global (JTA) transaction
then the autocommit is false regardless of what
value is specified here. Use true here if the client
only reads the data and false if the client also
modifies the data.
Use DatabaseTransactionFactory.commitTransaction
to commit the transaction.strDataSourceName - - data source which will be used to get connectionsstrUser - - user name to connect to the databasestrPassword - - password to the database
OSSDatabaseAccessException - - if connection cannot be establishedreturnConnection(java.sql.Connection)void returnConnection(java.sql.Connection cntDBConnection)
cntDBConnection - - connection to a database to release, may be nullrequestConnection(boolean)java.lang.String getDatabaseDriver()
void setDatabaseDriver(java.lang.String strDatabaseDriver)
strDatabaseDriver - - The database driver to setjava.lang.String getRealDatabaseDriver()
java.lang.String getDatabasePassword()
void setDatabasePassword(java.lang.String strDatabasePassword)
strDatabasePassword - - The database password to setjava.lang.String getDatabaseURL()
void setDatabaseURL(java.lang.String strDatabaseURL)
strDatabaseURL - - The database URL to setjava.lang.String getDatabaseUser()
void setDatabaseUser(java.lang.String strDatabaseUser)
strDatabaseUser - - The database user to setjava.lang.String getDatabaseAdminUser()
void setDatabaseAdminUser(java.lang.String strDatabaseUser)
strDatabaseUser - - The database user to setjava.lang.String getDatabaseAdminPassword()
void setDatabaseAdminPassword(java.lang.String strDatabasePassword)
strDatabasePassword - - The database password to setboolean getUseAdminDataSource()
void setUseAdminDataSource(boolean bUseAdminDataSource)
bUseAdminDataSource - - if true then separate datasource shoud be
used for administration connection
void loadDefaultDatabaseProperties()
throws OSSConfigException,
OSSDatabaseAccessException
OSSConfigException - - problem locating or accessing config file
OSSDatabaseAccessException - - problem accessing the database
void addDataSource(java.lang.String strDataSourceName,
java.lang.String strDriverName,
java.lang.String strUrl,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
strDataSourceName - - data source namestrDriverName - - name of the JDBC driverstrUrl - - url by which data source connects to the databasestrUser - - user name to connects to the databasestrPassword - - password to connects to the database
OSSDatabaseAccessException - - data source with the same name already
existsvoid setDefaultDataSourceName(java.lang.String strDataSourceName)
strDataSourceName - - data source which will be used to get connectionsjava.lang.String getDefaultDataSourceName()
boolean isDataSourceDefined(java.lang.String strDataSourceName)
strDataSourceName - - name of the data source to check for
void stop()
throws OSSException
OSSException - - problem stopping connection factory.int getTotalRequestedConnectionCount()
int getRequestedConnectionCount()
int getRequestedConnectionCount(java.lang.String strDataSourceName)
strDataSourceName - - data source which will be used to get connections
java.lang.String debug()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||