Class DatabaseSupport
- java.lang.Object
-
- org.linuxforhealth.fhir.database.utils.pool.DatabaseSupport
-
- All Implemented Interfaces:
IConnectionProvider,ITransactionProvider
public class DatabaseSupport extends java.lang.Object implements IConnectionProvider, ITransactionProvider
Support class for managing connections to a database for utility apps
-
-
Constructor Summary
Constructors Constructor Description DatabaseSupport(java.util.Properties dbProperties, DbType dbType)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommitTransaction()Commit the current transaction if there's an actual connection associated with this thread (i.e.voiddescribe(java.lang.String prefix, java.lang.StringBuilder cfg, java.lang.String key)Describe self, for writing configuration information to log file for test record purposesjava.sql.ConnectiongetConnection()Obtain a new connection to a data-source which this provider has been configured for.IDatabaseAdaptergetDatabaseAdapter()Get the configured database adapterITransactiongetTransaction()Obtain the transaction to use on this threadIDatabaseTranslatorgetTranslator()Get the IDatabaseTranslator for the configured database typevoidinit()Build the database configuration from the configured propertiesvoidrollbackTransaction()Roll back the transaction for the connection associated with this thread, if one exists-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.linuxforhealth.fhir.database.utils.api.IConnectionProvider
getPoolSize
-
-
-
-
Constructor Detail
-
DatabaseSupport
public DatabaseSupport(java.util.Properties dbProperties, DbType dbType)Public constructor- Parameters:
dbProperties-dbType-
-
-
Method Detail
-
init
public void init()
Build the database configuration from the configured properties
-
getDatabaseAdapter
public IDatabaseAdapter getDatabaseAdapter()
Get the configured database adapter- Returns:
-
getTranslator
public IDatabaseTranslator getTranslator()
Get the IDatabaseTranslator for the configured database type- Specified by:
getTranslatorin interfaceIConnectionProvider- Returns:
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLExceptionDescription copied from interface:IConnectionProviderObtain a new connection to a data-source which this provider has been configured for.- Specified by:
getConnectionin interfaceIConnectionProvider- Returns:
- Throws:
java.sql.SQLException
-
getTransaction
public ITransaction getTransaction()
Description copied from interface:ITransactionProviderObtain the transaction to use on this thread- Specified by:
getTransactionin interfaceITransactionProvider- Returns:
-
commitTransaction
public void commitTransaction() throws java.sql.SQLExceptionDescription copied from interface:IConnectionProviderCommit the current transaction if there's an actual connection associated with this thread (i.e. if getConnection() has been called at least once), otherwise do nothing.- Specified by:
commitTransactionin interfaceIConnectionProvider- Throws:
java.sql.SQLException
-
rollbackTransaction
public void rollbackTransaction() throws java.sql.SQLExceptionDescription copied from interface:IConnectionProviderRoll back the transaction for the connection associated with this thread, if one exists- Specified by:
rollbackTransactionin interfaceIConnectionProvider- Throws:
java.sql.SQLException
-
describe
public void describe(java.lang.String prefix, java.lang.StringBuilder cfg, java.lang.String key)Description copied from interface:IConnectionProviderDescribe self, for writing configuration information to log file for test record purposes- Specified by:
describein interfaceIConnectionProvider
-
-