Package org.apache.empire.db.context
Class DBContextBase
java.lang.Object
org.apache.empire.db.context.DBContextBase
- All Implemented Interfaces:
DBContext
- Direct Known Subclasses:
DBContextStatic
DBContextBase
Basic implementation of the DBContext interface which can be used as a base class for own implmentations
- Author:
- rainer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendRollbackHandler(DBRollbackHandler handler) protected voidhelper to close a connection on discardvoidcommit()final DBCommandCreates a new Command object for the given databaseprotected DBUtilsFactory function for Utils creationvoiddiscard()Discard connection releated ressources WARING: No gurarantee it will be calledfinal intexecuteDelete(DBTable from, DBCommand cmd) Executes a Delete statement from a command objectfinal intexecuteInsert(DBCommand cmd) Executes an Insert statement from a command objectfinal intexecuteInsertInto(DBTable table, DBCommand cmd) Executes an InsertInfo statement from a command objectfinal intexecuteSQL(String sqlCmd, Object[] sqlParams) Executes an SQLStatmentfinal intexecuteUpdate(DBCommand cmd) Executes an Update statement from a command objectprotected abstract ConnectiongetConnection(boolean required) protected abstract DBRollbackManagergetRollbackManager(boolean required) getUtils()abstract booleanreturns whether DBCommmand should automatically create a prepared statement with command params (?)voidremoveRollbackHandler(DBObject object) voidrollback()Discards all changes made since the previous commit/rollback and releases any database locks currently held by this Connection.protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.empire.db.DBContext
getDbms, isRollbackHandlingEnabled
-
Constructor Details
-
DBContextBase
public DBContextBase()
-
-
Method Details
-
createUtils
Factory function for Utils creation- Returns:
- the utils implementation
-
setUtils
-
getUtils
-
getConnection
-
getRollbackManager
-
getConnection
- Specified by:
getConnectionin interfaceDBContext
-
isPreparedStatementsEnabled
public abstract boolean isPreparedStatementsEnabled()returns whether DBCommmand should automatically create a prepared statement with command params (?) Event if this is false, is still possible to manually add command params using cmd.addCmdParam();- Returns:
- true if automatic prepared Statements are enabled or false if not
-
createCommand
Creates a new Command object for the given database- Specified by:
createCommandin interfaceDBContext- Returns:
- the command object.
-
executeSQL
Executes an SQLStatment- Specified by:
executeSQLin interfaceDBContext- Parameters:
sqlCmd- the SQL-CommandsqlParams- a list of objects to replace sql parameters
-
executeInsert
Executes an Insert statement from a command object- Specified by:
executeInsertin interfaceDBContext- Parameters:
cmd- the command object containing the insert command- Returns:
- the number of records that have been inserted with the supplied statement
-
executeInsertInto
Executes an InsertInfo statement from a command object- Specified by:
executeInsertIntoin interfaceDBContext- Parameters:
table- the table into which to insert the selected datacmd- the command object containing the selection command- Returns:
- the number of records that have been inserted with the supplied statement
-
executeUpdate
Executes an Update statement from a command object- Specified by:
executeUpdatein interfaceDBContext- Parameters:
cmd- the command object containing the update command- Returns:
- the number of records that have been updated with the supplied statement
-
executeDelete
Executes a Delete statement from a command object- Specified by:
executeDeletein interfaceDBContext- Parameters:
from- the database table from which to delete recordscmd- the command object containing the delete constraints- Returns:
- the number of records that have been deleted with the supplied statement
-
commit
public void commit() -
rollback
public void rollback()Discards all changes made since the previous commit/rollback and releases any database locks currently held by this Connection. -
appendRollbackHandler
- Specified by:
appendRollbackHandlerin interfaceDBContext
-
removeRollbackHandler
- Specified by:
removeRollbackHandlerin interfaceDBContext
-
discard
public void discard()Discard connection releated ressources WARING: No gurarantee it will be called -
closeConnection
protected void closeConnection()helper to close a connection on discard
-