It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Problem with MDB BMP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem with MDB BMP" Watch "Problem with MDB BMP" New topic

Problem with MDB BMP

Luciano A. Pozzo
Ranch Hand

Joined: Jun 20, 2005
Posts: 112

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

Message Driven Bean


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?

Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10441

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.

[My Blog] [JavaRanch Journal]
I agree. Here's the link:
subject: Problem with MDB BMP
It's not a secret anymore!