aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JDBC transactions in EJB 2.0 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 "JDBC transactions in EJB 2.0" Watch "JDBC transactions in EJB 2.0" New topic
Author

JDBC transactions in EJB 2.0

Raj Shenoy
Greenhorn

Joined: Aug 29, 2011
Posts: 6
Hi All,

This is my first post in code ranch!

I am using EJB 2.0 for coding my business logic and use entity beans for persistence.
But I have few business methods in stateless session beans, which uses JDBC queries.
I am using the default transactional attribute "Required".

The connection are retrieved from the data source deployed in the application server.
My concept(s) regarding JDBC when it is used in EJBs are:

1. When connection is retrieved from data source in EJB method, the executed SQL
queries form part of the transactions initiated by the container for the EJB method.
2. When a system exception is thrown the transaction will be rolled back by the container.

Now the issue is that the transaction rollback is not happening if SYSTEM exception is thrown in between.
I tried setting the attribute to "RequiresNew" for the EJB method to initiate new transaction, but still not working.
Could anyone point out, whether my understanding is right, or what I am doing wrong.


Thanks in advance,
Raj.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Which application server (which version) and which database server are you using?

[My Blog] [JavaRanch Journal]
Raj Shenoy
Greenhorn

Joined: Aug 29, 2011
Posts: 6
Hi Jaikiran,

I am using Jboss 4.0.4.GA and MySQL 5.1.50.


Regards.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Raj Shenoy wrote:MySQL 5.1.50.


MySQL has 2 different engines. InnoDB and MyISAM http://dev.mysql.com/doc/refman/5.1/en/storage-engines.html. Only InnoDB supports transactions. So make sure that you have configured your DB tables to use InnoDB. Check the MySQL manual for more details.
Raj Shenoy
Greenhorn

Joined: Aug 29, 2011
Posts: 6
Hi All,

Would be grateful for any suggestions, pointers.


Regards.
Raj Shenoy
Greenhorn

Joined: Aug 29, 2011
Posts: 6
Hi JaiKiran,

I didn't refresh the page, and hence posted last message.
Really thankful for your quick reply. Yes we use MyIsam engine.
I guess now I have my answer to further research on!


Thanks once again.
Regards.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC transactions in EJB 2.0