|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.persist.db.DatabaseConnectionFactoryImpl
public abstract class DatabaseConnectionFactoryImpl
Base class for implementation of factories for retrieving and returning of database connections. Most likely one project will use only one implementation of connection factory therefore this class contains factory methods to instantiate and return default instance of connection factory even though it still allows multiple instances of connection factory to exist since all attributes are non-static.
| Field Summary | |
|---|---|
static java.lang.String |
ADMIN_DATASOURCE_NAME
Name that will be used for datasource which should have administration priviledges to setup the database. |
static java.lang.String |
DATABASE_ADMIN_PASSWORD
Name of the property containing user password to connect to the database, as administrator e.g. |
static java.lang.String |
DATABASE_ADMIN_USER
Name of the property containing user name to connect to the database, as an administrator e.g. |
static java.lang.String |
DATABASE_DRIVER
Name of the property containing driver to use to connect to the database, e.g. |
static java.lang.String |
DATABASE_PASSWORD
Name of the property containing user password to connect to the database, e.g. |
static java.lang.String |
DATABASE_URL
Name of the property containing URL to connect to the database, e.g. |
static java.lang.String |
DATABASE_USE_ADMIN_DATAROURCE
Name of the property specifying if to use an separate datasource to obtain administration connection instead of just using the default data source with separate credentials. |
static boolean |
DATABASE_USE_ADMIN_DATAROURCE_DEFAULT
Default value for flag specifying if to use separate datasource for admin connections. |
static java.lang.String |
DATABASE_USER
Name of the property containing user name to connect to the database, e.g. |
protected boolean |
m_bUseAdminDataSource
If true then use an separate datasource to obtain administration connection instead of just using the default data source with separate credentials. |
protected int |
m_iRequestedConnectionCount
How many connections were requested and not returned. |
protected java.lang.String |
m_strDatabaseAdminPassword
Password for user with with administration priviledges to connect to the database, e.g. |
protected java.lang.String |
m_strDatabaseAdminUser
User name with administration priviledges to connect to the database, e.g. |
protected java.lang.String |
m_strDatabaseDriver
Driver to use to connect to the database, e.g. |
protected java.lang.String |
m_strDatabasePassword
Password to connect to the database, e.g. |
protected java.lang.String |
m_strDatabaseURL
URL to connect to the database, e.g. |
protected java.lang.String |
m_strDatabaseUser
User name to connect to the database, e.g. |
protected java.lang.String |
m_strRealDatabaseDriver
Real driver which is used to connect to database. |
protected DatabaseTransactionFactoryImpl |
m_transactionFactory
This is concrete implementation of database transaction factory, which will be used to manage transactions across connections allocated by this database connection factory. |
static java.lang.String |
SPY_CONFIG_FILE_NAME
Name of the configuration file for the spy driver. |
static java.lang.String |
SPY_DRIVER_IDENTIFICATION
This string is used to identify JDBC spy driver. |
static java.lang.String |
SPY_REALDRIVER
Name of the property which contains identification of real driver user by the spy driver. |
| Constructor Summary | |
|---|---|
DatabaseConnectionFactoryImpl()
Default constructor. |
|
DatabaseConnectionFactoryImpl(DatabaseTransactionFactoryImpl transactionFactory)
Default constructor. |
|
DatabaseConnectionFactoryImpl(java.lang.String strDriver,
java.lang.String strURL,
java.lang.String strUser,
java.lang.String strPassword,
DatabaseTransactionFactoryImpl transactionFactory)
Constructor with explicitely specified JDBC driver. |
|
| Method Summary | |
|---|---|
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. |
static DatabaseConnectionFactory |
getInstance()
Get the default database connection factory. |
java.lang.String |
getRealDatabaseDriver()
Get real driver name which is used to connect to database. |
int |
getTotalRequestedConnectionCount()
Get number for connections 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. |
protected void |
initializeConnection(java.sql.Connection cntDBConnection,
boolean bAutoCommit)
Initialize connection to the default state so it can be used to work with the database. |
protected void |
initializeDriver(java.lang.String strDatabaseDriver)
Initialize specified database driver. |
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. |
protected abstract java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory#requestConnection() to get connection which is not tied to the transactional manager. |
protected abstract java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String) to get connection which is not tied to the transactional manager. |
protected abstract java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String, String) to get connection which is not tied to the transactional manager. |
protected abstract java.sql.Connection |
requestNonTransactionalConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #requestConnection(String, String, String) to get connection which is not tied to the transactional manager. |
void |
returnConnection(java.sql.Connection cntDBConnection)
Release connection to a database. |
abstract void |
returnNonTransactionalConnection(java.sql.Connection cntDBConnection)
This method is a delegation method for now final org.opensubsystems.core.persist.db.DatabaseConnectionFactory #returnConnection(java.sql.Connection) to return connection which is not tied to the transactional manager. |
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. |
static void |
setInstance(DatabaseConnectionFactory dcfDefaultConnectionFactory)
Set default database connection factory instance. |
void |
setTransactionFactory(DatabaseTransactionFactoryImpl transactionFactory)
Set the transaction factory for this connection factory. |
void |
setUseAdminDataSource(boolean bUseAdminDataSource)
Sets the flag specifying if to use separate datasource instead just different creadentials to obtain administrator connection. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opensubsystems.core.persist.db.DatabaseConnectionFactory |
|---|
addDataSource, debug, getDefaultDataSourceName, getRequestedConnectionCount, getRequestedConnectionCount, isDataSourceDefined, setDefaultDataSourceName, stop |
| Field Detail |
|---|
public static final java.lang.String DATABASE_DRIVER
public static final java.lang.String DATABASE_URL
public static final java.lang.String DATABASE_USER
public static final java.lang.String DATABASE_PASSWORD
public static final java.lang.String DATABASE_ADMIN_USER
public static final java.lang.String DATABASE_ADMIN_PASSWORD
public static final java.lang.String DATABASE_USE_ADMIN_DATAROURCE
public static final boolean DATABASE_USE_ADMIN_DATAROURCE_DEFAULT
public static final java.lang.String SPY_DRIVER_IDENTIFICATION
public static final java.lang.String SPY_CONFIG_FILE_NAME
public static final java.lang.String SPY_REALDRIVER
public static final java.lang.String ADMIN_DATASOURCE_NAME
protected DatabaseTransactionFactoryImpl m_transactionFactory
protected int m_iRequestedConnectionCount
protected java.lang.String m_strDatabaseDriver
m_strRealDatabaseDriverprotected java.lang.String m_strRealDatabaseDriver
protected java.lang.String m_strDatabaseURL
DATABASE_URLprotected java.lang.String m_strDatabaseUser
DATABASE_USERprotected java.lang.String m_strDatabasePassword
DATABASE_PASSWORDprotected java.lang.String m_strDatabaseAdminUser
DATABASE_USERprotected java.lang.String m_strDatabaseAdminPassword
DATABASE_PASSWORDprotected boolean m_bUseAdminDataSource
DATABASE_USE_ADMIN_DATAROURCE| Constructor Detail |
|---|
public DatabaseConnectionFactoryImpl()
public DatabaseConnectionFactoryImpl(DatabaseTransactionFactoryImpl transactionFactory)
transactionFactory - - transaction factory to use for this
connection factory, can be null
public DatabaseConnectionFactoryImpl(java.lang.String strDriver,
java.lang.String strURL,
java.lang.String strUser,
java.lang.String strPassword,
DatabaseTransactionFactoryImpl transactionFactory)
throws OSSConfigException,
OSSDatabaseAccessException
strDriver - - JDBC driver to connect to the databasestrURL - - URL of database to connect tostrUser - - user name to connect to the databasestrPassword - - password to the databasetransactionFactory - - transaction factory to use for this
connection factory, can be null
OSSConfigException - - problem accessing or locating the config file.
OSSDatabaseAccessException - - an error has occured accessing
the database| Method Detail |
|---|
public static DatabaseConnectionFactory getInstance()
throws OSSException
OSSException - - problem connecting to databasepublic static void setInstance(DatabaseConnectionFactory dcfDefaultConnectionFactory)
dcfDefaultConnectionFactory - - new default database
connection factory instancegetInstance()
public final java.sql.Connection requestConnection(boolean bAutoCommit)
throws OSSDatabaseAccessException
requestConnection in interface DatabaseConnectionFactorybAutoCommit - - 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 establishedDatabaseConnectionFactory.returnConnection(java.sql.Connection)
public final java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
requestConnection in interface DatabaseConnectionFactorybAutoCommit - - 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 establishedDatabaseConnectionFactory.returnConnection(java.sql.Connection)
public final java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName)
throws OSSDatabaseAccessException
requestConnection in interface DatabaseConnectionFactorybAutoCommit - - 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 establishedDatabaseConnectionFactory.returnConnection(java.sql.Connection)
public final java.sql.Connection requestConnection(boolean bAutoCommit,
java.lang.String strDataSourceName,
java.lang.String strUser,
java.lang.String strPassword)
throws OSSDatabaseAccessException
requestConnection in interface DatabaseConnectionFactorybAutoCommit - - 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 establishedDatabaseConnectionFactory.returnConnection(java.sql.Connection)public final void returnConnection(java.sql.Connection cntDBConnection)
returnConnection in interface DatabaseConnectionFactorycntDBConnection - - connection to a database to release, may be nullDatabaseConnectionFactory.requestConnection(boolean)public void setTransactionFactory(DatabaseTransactionFactoryImpl transactionFactory)
transactionFactory - - the transaction factory to set.public java.lang.String getDatabaseDriver()
getDatabaseDriver in interface DatabaseConnectionFactorypublic void setDatabaseDriver(java.lang.String strDatabaseDriver)
setDatabaseDriver in interface DatabaseConnectionFactorystrDatabaseDriver - - The database driver to setpublic java.lang.String getDatabasePassword()
getDatabasePassword in interface DatabaseConnectionFactorypublic void setDatabasePassword(java.lang.String strDatabasePassword)
setDatabasePassword in interface DatabaseConnectionFactorystrDatabasePassword - - The database password to setpublic java.lang.String getDatabaseURL()
getDatabaseURL in interface DatabaseConnectionFactorypublic void setDatabaseURL(java.lang.String strDatabaseURL)
setDatabaseURL in interface DatabaseConnectionFactorystrDatabaseURL - - The database URL to setpublic java.lang.String getDatabaseUser()
getDatabaseUser in interface DatabaseConnectionFactorypublic void setDatabaseUser(java.lang.String strDatabaseUser)
setDatabaseUser in interface DatabaseConnectionFactorystrDatabaseUser - - The database user to setpublic java.lang.String getDatabaseAdminUser()
getDatabaseAdminUser in interface DatabaseConnectionFactorypublic void setDatabaseAdminUser(java.lang.String strDatabaseUser)
setDatabaseAdminUser in interface DatabaseConnectionFactorystrDatabaseUser - - The database user to setpublic java.lang.String getDatabaseAdminPassword()
getDatabaseAdminPassword in interface DatabaseConnectionFactorypublic void setDatabaseAdminPassword(java.lang.String strDatabasePassword)
setDatabaseAdminPassword in interface DatabaseConnectionFactorystrDatabasePassword - - The database password to setpublic boolean getUseAdminDataSource()
getUseAdminDataSource in interface DatabaseConnectionFactorypublic void setUseAdminDataSource(boolean bUseAdminDataSource)
setUseAdminDataSource in interface DatabaseConnectionFactorybUseAdminDataSource - - if true then separate datasource shoud be
used for administration connection
public void loadDefaultDatabaseProperties()
throws OSSConfigException,
OSSDatabaseAccessException
loadDefaultDatabaseProperties in interface DatabaseConnectionFactoryOSSConfigException - - problem locating or accessing config file
OSSDatabaseAccessException - - problem accessing the databasepublic int getTotalRequestedConnectionCount()
getTotalRequestedConnectionCount in interface DatabaseConnectionFactorypublic java.lang.String getRealDatabaseDriver()
getRealDatabaseDriver in interface DatabaseConnectionFactory
protected void initializeDriver(java.lang.String strDatabaseDriver)
throws OSSConfigException,
OSSDatabaseAccessException
strDatabaseDriver - - class name of JDBC driver
OSSConfigException - - problem accessing or locating the config file.
OSSDatabaseAccessException - - error initializing the driver
protected void initializeConnection(java.sql.Connection cntDBConnection,
boolean bAutoCommit)
throws java.sql.SQLException
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.cntDBConnection - - valid connection to the database
java.sql.SQLException - - problem initializing the connection
protected abstract java.sql.Connection requestNonTransactionalConnection(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)
protected abstract java.sql.Connection requestNonTransactionalConnection(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)
protected abstract java.sql.Connection requestNonTransactionalConnection(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)
protected abstract java.sql.Connection requestNonTransactionalConnection(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)public abstract void returnNonTransactionalConnection(java.sql.Connection cntDBConnection)
cntDBConnection - - connection to return, can be null
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||