struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <shirishchandra.sakh...@ubs.com>
Subject RE: [OT] Transaction Safe Java Code
Date Thu, 12 Jun 2003 16:01:56 GMT
In that case, the simplest thing to do would be 

1:Step 1:Commit 
 try {
	2:Call method 1
	3:call method 2
	}catch(Throwable t){
		rollback;
	}
	4:commit.
	finally{
		close connection;
	}

As u can see, if u do a commit just before method call1, its like u are starting a new transaction.
And u issue next commit only if m1 and m2 succeed else u rollaback to the previous state(prior
to m1)

HTH.

regards,
Shirish

-----Original Message-----
From: Navjot Singh [mailto:navjot.s@net4india.net]
Sent: Thursday, June 12, 2003 5:54 PM
To: Struts Users Mailing List
Subject: RE: [OT] Transaction Safe Java Code


Guess you have understood in wrong way.

Both are NOT data base methods, they could be any Java methods. I am not
talkin database txns. it's java transactions !!
I hope it make it clear.

-navjot singh


|-----Original Message-----
|From: Ravi Kora [mailto:rkora@1bigthink.com]
|Sent: Thursday, June 12, 2003 9:12 PM
|To: 'Struts Users Mailing List'
|Subject: RE: [OT] Transaction Safe Java Code
|
|
|If you r using the same connection for both the methods, then u can
|rollback. I wud suggest you to do sth like this
|Main method()
|{
|Open ur connection
|  Method1(pass connection object);
|  Method2(pass connection object);
| Rollback or commit the connection based on ur exceptions etc.
|Close the connection
|}
|
|I guess the above shud be doable.
|-Ravi
|
|> -----Original Message-----
|> From: Navjot Singh [mailto:navjot.s@net4india.net]
|> Sent: Thursday, June 12, 2003 11:14 AM
|> To: Struts Users Mailing List
|> Subject: [OT] Transaction Safe Java Code
|>
|>
|> Hi List,
|>
|> I have 2 methods that i am calling in same sequence.
|>
|> + txnMethod1()
|> + txnMethod2()
|>
|> I wish either both of them get _executed_ or none of them.
|>
|> Can i rollback the state to what was before method1's
|> _execution_ if method2 fails?
|>
|> Is it possible or i should start thinking simple?
|>
|> ---------------
|> regards
|> Navjot Singh
|> Net4India Ltd.
|>
|>
|> ---------------------------------------------------------------------
|> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
|> For additional commands, e-mail: struts-user-help@jakarta.apache.org
|>
|>
|
|
|
|---------------------------------------------------------------------
|To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
|For additional commands, e-mail: struts-user-help@jakarta.apache.org
|
|


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message