This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with MDB BMP

 
Luciano A. Pozzo
Ranch Hand
Posts: 112
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have a Message Driven Bean that execute one insert in the oracle database. This is a part of code:


Message Driven Bean


UserDAO



So, if I throw an exception in the method onMessage (after the insert occurs) the transaction is not rolled back.
What I forgot to do for the transaction control work?

Thank's
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to use a transaction aware resource (Datasource) in your UserDAO to insert that record in the database. Currently, you are using the connection in a auto-commit=true mode because of which the insert is not rolled back. Here's an extract from the Connection Javadoc:

Note: By default a Connection object is in auto-commit mode, which means that it automatically commits changes after executing each statement. If auto-commit mode has been disabled, the method commit must be called explicitly in order to commit changes; otherwise, database changes will not be saved.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic