Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC transactions in EJB 2.0

 
Raj Shenoy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which application server (which version) and which database server are you using?
 
Raj Shenoy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaikiran,

I am using Jboss 4.0.4.GA and MySQL 5.1.50.


Regards.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Would be grateful for any suggestions, pointers.


Regards.
 
Raj Shenoy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic