Sunil Mishra wrote:
> I am using 11 Oct 03 build.
>
> I have tried doing connection.setAutoCommit(false) in my Intereceptor. I
> tried to write to 2 other tables & return GRANT_OPREATION from my preInsert
> method.
> If any of these additional tables insert fails, then I would expect the main
> insert to also fail.
>
> Its not working though I have conn.setAutoCommit(false) before I do anything
> in the interceptor. It just goes ahead & commit it.
>
> Am I missing something here?
Hi Sunil,
could you post a code example ?
It's a bit of time I don't put my hands on DbFoprms, anyway, If I remember
correctly... you can write code within interceptors that fire
"jdbc queries" (insert, update, delete) on other tables.
If you set connection.setAutoCommit(false) to open a transaction, and then, if
you notice that your set of queries fail, then you should also call the
connection.rollback() operation to discard them.
On-the-fly example (hope it works ;^):
public void orderShip (String productId, String orderId)
{
try
{
con.setAutoCommit(false);
updateOrderItem(productId, orderId);
con.commit();
}
catch (SqlException ex)
{
con.rollback();
}
finally
{
if (con != null)
con.close();
}
}
Any database event checks if there is any interceptor object binded to the
current main table. If yes, the db event uses table.processInterceptors to
execute the interceptor's PRE_INSERT hook method.
If the interceptor ***returns a DENY_OPERATION code***, the table object fires
a SqlException catched by the Controller object.
The controller then calls cleanUpConnectionAfterException(con) method that:
- checks if the current connection belongs to an open transaction
(con != null) && (!con.getAutoCommit())
- if yes, calls
con.rollback();
con.setAutoCommit(true);
to discard transaction db operations and set the autoCommitMode to ON
to prevent to add more operations into the transaction queue.
Finally the controller executes closeConnections(connections) to
close the connection.
Your code example could be useful to build a transactional-interceptor test
case for dbforms...
Regards,
Luca
> ______________________________________________
> Sunil Mishra, Manager, ADP Wilco (India) Private Limited
> * +91-40-2340 8600 x-8202 ---- * +91-98490-61241
-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/
_______________________________________________
DbForms Mailing List
http://www.wap-force.net/dbforms