|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.framework.jdto.jdbc.wrapper.JDBCTemplate com.framework.jdto.jdbc.wrapper.StatementWrapper
This class is a Wrapper Class for java.sql.Statement. This class has the ability to take care of the transactions. if you want the current StatementWrapper Object to participate in a Transaction you must call the setSql() method with a boolean parameter as true on the current StatementWrapper Object. This Class takes care of getting and releasing the connection based on the current Objects transaction status.
This class also has the capability to Log the Statement SQL Query.
The Developer is not required to take care of closing the connection. This classes closes the connection after the execution of the query if the current StatementWrapper Object is not participating in any transaction. if the current StatementWrapper Object Participates in a Transaction then the TransactionContextManager will take care of closing the connection once the transaction is either committed or rolledback.
Constructor Summary | |
StatementWrapper()
|
|
StatementWrapper(DataSource ds)
|
Method Summary | |
boolean |
execute()
Executes the given SQL statement in the current StatementWrapper Object, which returns a boolean value. |
Object |
executeQuery(RowMapper row)
Executes the given SQL statement in the current StatementWrapper Object, which returns a single java.lang.Object type of object. |
int |
executeUpdate()
Executes the given SQL statement in the current StatementWrapper Object, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement. |
String |
getSql()
Returns the sql query that is associated with the current StatementWrapper object |
void |
setSql(String sql)
Sets the sql string to the current StatementWrapper Object and associates it with the java.sql.Statement. |
void |
setSql(String sql,
boolean avoidTransaction)
Sets the sql string to the current StatementWrapper Object and associates it with the java.sql.Statement. |
Methods inherited from class com.framework.jdto.jdbc.wrapper.JDBCTemplate |
setDatasource |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public StatementWrapper()
public StatementWrapper(DataSource ds)
Method Detail |
public String getSql()
public void setSql(String sql) throws DAOException
sql
- an SQL Query as java.lang.String
DAOException
- if database error occurspublic void setSql(String sql, boolean avoidTransaction) throws DAOException
If there is an existing transaction, which is started by TransactionContextManager's beginTransaction() method then this method dis associates the current Object from the currently running Transaction if the boolean parameter is true. But if the boolean parameter is false then this method associates the current Object to the currently running Transaction.
If there is no transaction running, this method doesn't associate the current object to any transaction irrespective the boolean value.
sql
- an SQL Query as java.lang.String
DAOException
- if any database error occurspublic Object executeQuery(RowMapper row) throws DAOException
If the current object is running in a transaction, on successful execution this sets the Current Transaction Status as STATUS_MARKED_COMMIT, otherwise it sets as STATUS_MARKED_ROLLBACK.
row
- any class that implements RowMapper Interface.
DAOException
- if any database error occurspublic int executeUpdate() throws DAOException
If the current object is running in a transaction, on successful execution this sets the Current Transaction Status as STATUS_MARKED_COMMIT, otherwise it sets as STATUS_MARKED_ROLLBACK.
DAOException
- if any database error occurspublic boolean execute() throws DAOException
If the current object is running in a transaction, on successful execution this sets the Current Transaction Status as STATUS_MARKED_COMMIT, otherwise it sets as STATUS_MARKED_ROLLBACK.
DAOException
- if any database error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |