public class TransactionalDb extends BasicDb
| Modifier and Type | Class and Description |
|---|---|
static interface |
TransactionalDb.TransactionCallback
Transaction callback interface
|
BasicDb.DbProperties| Constructor and Description |
|---|
TransactionalDb(BasicDb.DbProperties dbProperties) |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
beginTransaction() |
java.sql.Connection |
beginTransaction(java.lang.String schema) |
<V> V |
callInDbTransaction(java.util.concurrent.Callable<V> callable) |
void |
clearCache() |
void |
commitTransaction() |
void |
endTransaction() |
java.sql.Connection |
getConnection(java.lang.String schema) |
boolean |
isInTransaction() |
void |
registerCallback(TransactionalDb.TransactionCallback callback) |
void |
rollbackTransaction() |
void |
runInDbTransaction(java.lang.Runnable runnable) |
void |
setThreadQueryTimeout(int seconds)
Sets the timeout which will be used in
Statement.executeQuery(String) and
Statement.executeQuery(String) calls, done by this thread (for the current database). |
analyzeTables, getPooledConnection, getUrl, init, shutdownpublic TransactionalDb(BasicDb.DbProperties dbProperties)
public <V> V callInDbTransaction(java.util.concurrent.Callable<V> callable)
public void runInDbTransaction(java.lang.Runnable runnable)
public java.sql.Connection getConnection(java.lang.String schema)
throws java.sql.SQLException
getConnection in class BasicDbjava.sql.SQLExceptionpublic boolean isInTransaction()
public java.sql.Connection beginTransaction()
public java.sql.Connection beginTransaction(java.lang.String schema)
public void commitTransaction()
public void rollbackTransaction()
public void endTransaction()
public void registerCallback(TransactionalDb.TransactionCallback callback)
public void setThreadQueryTimeout(int seconds)
Sets the timeout which will be used in Statement.executeQuery(String) and
Statement.executeQuery(String) calls, done by this thread (for the current database).
Due to an issue in H2 implementation, Statement.setQueryTimeout(int) affects all statements in the
connection - see https://github.com/h2database/h2database/issues/243. So always reset to 0 after executing
the queries that must be limited
seconds - the new query timeout limit in seconds for the current thread; zero means there is no limitpublic void clearCache()