• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setRollbackOnly

 
sowmya thiru
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code that im running SFSB on WLS8.1. SFSB is called from a standalone java client.
clients transfer money from checking to savings. in my db i have 20$ in Checking. I make an attmpt to transfer $60 from checking to savings.
public void transferToSaving(double amount) throws InsufficientBalanceException {
checkingBalance -= amount; savingBalance += amount;
try { updateChecking(checkingBalance); if (checkingBalance < 0.00) {
System.out.println("loop starting"); //THIS LOOP IS PUT DELIBERATELy, // so that I can check DB if value has been deducted from checking table
for (int i = 0 ; i < 1000000000; i++) { }
context.setRollbackOnly(); throw new InsufficientBalanceException(); } updateSaving(savingBalance); } catch (SQLException ex) { throw new EJBException ("Transaction failed due to SQLException: " + ex.getMessage()); }
}
At end of above method, i see -40 in my checking account, and savings account incremented by 60$
my question. why updated to checking table has not rolled back?
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the future please avoid cross-posting the same question to multiple forums. I have posted a response here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic