public interface DatabaseService extends Contexed, AppContextService<DatabaseService>, CloseRegistry
Modifier and Type | Field and Description |
---|---|
static Feature |
LOG_INSERT_FEATURE |
static Feature |
LOG_QUERY_FEATURE |
static Feature |
LOG_UPDATE |
static Feature |
USE_SQL_DISTICT_FEATURE |
Modifier and Type | Method and Description |
---|---|
void |
commitTransaction()
flush changes since start of last commit.
|
java.util.Map<java.lang.String,java.lang.Object> |
getConnectionAttributes()
get a map of information about the connection
|
SQLContext |
getSQLContext()
get
SQLContext using the default ConfigService |
SQLContext |
getSQLContext(java.lang.String tag)
get alternative database
SQLContext
If the tag is null it returns the same SQLContext as
getSQLContext() . |
SQLContext |
getSQLContext(java.lang.String tag,
java.util.Properties config_props)
get a {SQLContext} based on properties
|
void |
handleError(java.lang.String message,
java.sql.SQLException e)
Handle an unexpected database exception.
|
boolean |
inTransaction()
Are we already in a transaction
|
void |
logError(java.lang.String message,
java.sql.SQLException e)
handle an
SQLException directly. |
void |
rollbackTransaction()
Abort changes since start or last commit
|
void |
startTransaction()
Start a database transaction
Transactions cannot be nested so use
inTransaction() if possible doubt. |
void |
stopTransaction()
finish transaction (includes commit).
|
int |
transactionStage()
returns the number of times
commitTransaction() has been called
since the last transaction start. |
getContext
getType
cleanup
addClosable, closeRetainedClosables, removeClosable
static final Feature LOG_QUERY_FEATURE
static final Feature USE_SQL_DISTICT_FEATURE
static final Feature LOG_INSERT_FEATURE
static final Feature LOG_UPDATE
SQLContext getSQLContext(java.lang.String tag, java.util.Properties config_props) throws java.sql.SQLException
tag
- config_props
- SQLContext
java.sql.SQLException
SQLContext getSQLContext() throws java.sql.SQLException
SQLContext
using the default ConfigService
SQLContext
to databasejava.sql.SQLException
SQLContext getSQLContext(java.lang.String tag) throws java.sql.SQLException
SQLContext
If the tag is null it returns the same SQLContext
as
getSQLContext()
.tag
- java.sql.SQLException
boolean inTransaction()
int transactionStage()
commitTransaction()
has been called
since the last transaction start.
If this returns 0 then a roll-back will return to the state at startTransaction()
if greater than zero
there have been intermediate commits.
To aid in testing the value is not reset to zero until the next call to startTransaction()
void startTransaction()
inTransaction()
if possible doubt.void rollbackTransaction()
void commitTransaction()
CleanupService
unless the transaction phases all
make sense in their own right.void stopTransaction()
void handleError(java.lang.String message, java.sql.SQLException e) throws DataFault
DataFault
however
this also allow special handing of certain classes of error such as SQLTransientException
se
- DataException
DataFault
void logError(java.lang.String message, java.sql.SQLException e)
SQLException
directly. Normally this will just log the error however
this also allow special handing of certain classes of error such as SQLTransientException
smessage
- e
- java.util.Map<java.lang.String,java.lang.Object> getConnectionAttributes() throws java.lang.Exception
java.lang.Exception