• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transaction not rolling back

 
Pappu Kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Weblogic 6.1 sp3 and Sybase 12.5 DB.

I have a peice of code....something like this -


METHOD A
Look up userTx;
try{
userTx.begin();
getTxDataSource().getConnection();
update table A;
call METGOD B
userTx.commit();
}
catch(exception e){
userTx.rollback();
}



METHOD B
try{
Look up userTx;
realize its under a TX context so doesnt call begin;
getTxDataSource().getConnection();
Read Table A and Update Table B;
Not my TX so dont commit;
}catch(Exception ex){
Not my TX so mark for rollback;
throw ex;
}

Both Table A and Table B are in the same database.

Now when Method B throws an exception....the DB changes are not getting rolled back.

Can someone tell me , what could possibly be going wrong here ?
I am not using a XADataSource for my TX DataSource , i use the regular connection pool (com.sybase.jdbc2.jdbc.SybDriver is the JDBC driver).
But in the DataSource config i set EnableTwoPhaseCommit=true.

I am thinking....do i have to use javax.transaction.xa package....i am not using it in my code so far.

Please suggest
 
Rajiv Babu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I suspect your userTxn objects are different. Pass the object as argument to method B and use the same connection also. It should work.

regards,
Rajiv
 
Pappu Kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UserTx part is OK , when check for the TX status inside Method B...it shows as TX ACTIVE status.
 
Pappu Kumar
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
another thing if i do a "select @@spid" query inside METHODA and METHODB , they return deifferent spid's. I believe that somehow the app server is not handling the TX DATASOURCE well enough...the spid's have to be the same for one transaction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!