How to use transactions to execute code currently?

Hi All,

i am attempting to perform a JDBC commit and an update to a log file, ie. i am recording the updates in a log file so i can use for recovery, however from the point of the transaction is commited to the point at which it is updated into the file the system can be exited thus the database and log file are out of sync. I was wondering if there are any transaction mechanisms that i can use to perform these at the same time so if the records get commited then the log is also updated however if either are missed then both are rolledback eg.

try{

myTransaction.begin();

connection.comitt();

updateLog();

myTransaction.comitt();

}catch(Exception ex){

myTransaction.rollback();

}

any help or advice will be greatly appreciated

Message was edited by:

uddinr0121

Message was edited by:

uddinr0121

[1067 byte] By [uddinr0121a] at [2007-11-27 10:15:12]
# 1

Don't keep your own log file. Use a database that keeps a log file for you, so it is automatically maintained within the same transaction.

ejpa at 2007-7-28 15:38:05 > top of Java-index,Core,Core APIs...
# 2

its not only just databases it will be used for i am also writing to flat files therefore if i have one way that i can have one mechanism for any type of writing

uddinr0121a at 2007-7-28 15:38:05 > top of Java-index,Core,Core APIs...
# 3

If you want transactions you have to use a database.

ejpa at 2007-7-28 15:38:05 > top of Java-index,Core,Core APIs...
# 4

You can also go over to Jini.org and take a look at their transaction management:

"A series of operations, either within a single service or spanning multiple services, can be wrapped in a transaction. The Jini transaction interfaces supply a service protocol needed to coordinate a two-phase commit. How transactions are implemented--and indeed, the very semantics of the notion of a transaction--is left up to the service using those interfaces."

cooper6a at 2007-7-28 15:38:05 > top of Java-index,Core,Core APIs...
# 5

I am not sure that you can consider a log file and a database two different global resources, but you can always use a transaction service to wrap your opperation. Check Atomikos.

gs03anna at 2007-7-28 15:38:05 > top of Java-index,Core,Core APIs...