Class DatabaseService
- java.lang.Object
-
- technology.openpool.ldap.adapter.sql.impl.DatabaseService
-
- All Implemented Interfaces:
Transactional
public class DatabaseService extends Object implements Transactional
A facade for managed database access.
-
-
Constructor Summary
Constructors Constructor Description DatabaseService(org.slf4j.Logger logger, String driver, String url, String user, String password, int minIdle, int maxIdle, int maxTotal, int maxOpenPreparedStatements, int isolationLevel, boolean applyNativeSql)Instantiates a new DatabaseService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CloseableTransactiongetCloseableTransaction()Creates a closeable transaction for undefined lifetime.booleanhasUpdatedSchema()Check if the schema was updated.voidshutdown()Shutdown method.voidstartup()Startup method.voidwithTransaction(Consumer<QueryDefFactory> block)Creates a transaction for the lifetime of a code block.<T> TwithTransaction(Function<QueryDefFactory,T> block)Creates a transaction for the lifetime of a code block.
-
-
-
Constructor Detail
-
DatabaseService
public DatabaseService(org.slf4j.Logger logger, String driver, String url, String user, String password, int minIdle, int maxIdle, int maxTotal, int maxOpenPreparedStatements, int isolationLevel, boolean applyNativeSql)Instantiates a new DatabaseService.- Parameters:
logger- the logger instancedriver- the database driverurl- the URL to the endpoint of the databaseuser- the name of the database userpassword- the password of the database userminIdle- the minimum number of idle connections used for connection poolingmaxIdle- the maximum number of idle connections used for connection poolingmaxTotal- the maximum number of total connections used for connection poolingmaxOpenPreparedStatements- the maximum number of open prepared statementsisolationLevel- the isolation level used for transactionsapplyNativeSql- the flag to enable or disable native SQL for batch processing
-
-
Method Detail
-
startup
public void startup()
Startup method.
-
shutdown
public void shutdown()
Shutdown method.
-
hasUpdatedSchema
public boolean hasUpdatedSchema()
Check if the schema was updated.- Returns:
- the boolean
-
withTransaction
public <T> T withTransaction(Function<QueryDefFactory,T> block)
Description copied from interface:TransactionalCreates a transaction for the lifetime of a code block.- Specified by:
withTransactionin interfaceTransactional- Parameters:
block- the code block- Returns:
- the return value of the code block
-
withTransaction
public void withTransaction(Consumer<QueryDefFactory> block)
Description copied from interface:TransactionalCreates a transaction for the lifetime of a code block.- Specified by:
withTransactionin interfaceTransactional- Parameters:
block- the code block
-
getCloseableTransaction
public CloseableTransaction getCloseableTransaction()
Description copied from interface:TransactionalCreates a closeable transaction for undefined lifetime.- Specified by:
getCloseableTransactionin interfaceTransactional- Returns:
- the closeable transaction
-
-