public class WrappedDatabaseService extends java.lang.Object implements DatabaseService
DatabaseService
wrapper that can beused to generate a tabe
showing the current active connectionsLOG_INSERT_FEATURE, LOG_QUERY_FEATURE, LOG_UPDATE, USE_SQL_DISTICT_FEATURE
Constructor and Description |
---|
WrappedDatabaseService(AppContext conn) |
WrappedDatabaseService(DatabaseService inner,
java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
static void |
add(WrappedDatabaseService serv) |
void |
addClosable(java.lang.AutoCloseable c) |
void |
cleanup()
AppContext is being closed. |
void |
closeRetainedClosables() |
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
|
AppContext |
getContext() |
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
DatabaseService.getSQLContext() . |
SQLContext |
getSQLContext(java.lang.String tag,
java.util.Properties config_props)
get a {SQLContext} based on properties
|
static Table |
getStatusTable() |
java.lang.Class<? super DatabaseService> |
getType()
Returns the type of service the class should be registered under.
|
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. |
static void |
remove(WrappedDatabaseService serv) |
void |
removeClosable(java.lang.AutoCloseable c) |
void |
rollbackTransaction()
Abort changes since start or last commit
|
void |
startTransaction()
Start a database transaction
Transactions cannot be nested so use
DatabaseService.inTransaction() if possible doubt. |
void |
stopTransaction()
finish transaction (includes commit).
|
int |
transactionStage()
returns the number of times
DatabaseService.commitTransaction() has been called
since the last transaction start. |
public WrappedDatabaseService(AppContext conn)
conn
- public WrappedDatabaseService(DatabaseService inner, java.lang.String id)
public static void add(WrappedDatabaseService serv)
public static void remove(WrappedDatabaseService serv)
public static Table getStatusTable()
public AppContext getContext()
getContext
in interface Contexed
public java.lang.Class<? super DatabaseService> getType()
AppContextService
getType
in interface AppContextService<DatabaseService>
public void cleanup()
AppContextCleanup
AppContext
is being closed.
Only use this for cleanup that can't be handled by
normal garbage collection or for state which is never returned by reference.cleanup
in interface AppContextCleanup
public void addClosable(java.lang.AutoCloseable c)
addClosable
in interface CloseRegistry
public void removeClosable(java.lang.AutoCloseable c)
removeClosable
in interface CloseRegistry
public SQLContext getSQLContext(java.lang.String tag, java.util.Properties config_props) throws java.sql.SQLException
DatabaseService
getSQLContext
in interface DatabaseService
SQLContext
java.sql.SQLException
public SQLContext getSQLContext() throws java.sql.SQLException
DatabaseService
SQLContext
using the default ConfigService
getSQLContext
in interface DatabaseService
SQLContext
to databasejava.sql.SQLException
public SQLContext getSQLContext(java.lang.String tag) throws java.sql.SQLException
DatabaseService
SQLContext
If the tag is null it returns the same SQLContext
as
DatabaseService.getSQLContext()
.getSQLContext
in interface DatabaseService
java.sql.SQLException
public boolean inTransaction()
DatabaseService
inTransaction
in interface DatabaseService
public int transactionStage()
DatabaseService
DatabaseService.commitTransaction()
has been called
since the last transaction start.
If this returns 0 then a roll-back will return to the state at DatabaseService.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 DatabaseService.startTransaction()
transactionStage
in interface DatabaseService
public void startTransaction()
DatabaseService
DatabaseService.inTransaction()
if possible doubt.startTransaction
in interface DatabaseService
public void rollbackTransaction()
DatabaseService
rollbackTransaction
in interface DatabaseService
public void commitTransaction()
DatabaseService
CleanupService
unless the transaction phases all
make sense in their own right.commitTransaction
in interface DatabaseService
public void stopTransaction()
DatabaseService
stopTransaction
in interface DatabaseService
public void handleError(java.lang.String message, java.sql.SQLException e) throws DataFault
DatabaseService
DataFault
however
this also allow special handing of certain classes of error such as SQLTransientException
shandleError
in interface DatabaseService
DataFault
public void logError(java.lang.String message, java.sql.SQLException e)
DatabaseService
SQLException
directly. Normally this will just log the error however
this also allow special handing of certain classes of error such as SQLTransientException
slogError
in interface DatabaseService
public void closeRetainedClosables()
closeRetainedClosables
in interface CloseRegistry
public java.util.Map<java.lang.String,java.lang.Object> getConnectionAttributes() throws java.lang.Exception
DatabaseService
getConnectionAttributes
in interface DatabaseService
java.lang.Exception