This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

setRollbackOnly

 
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?
 
Ranch Hand
Posts: 2713
  • 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.
 
Now I am super curious what sports would be like if we allowed drugs and tiny ads.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic