[jboss-user] [Beginner's Corner] - JDBC inside CMT

Mads Moelgaard Andersen do-not-reply at jboss.com
Wed Aug 18 07:01:32 EDT 2010

Mads Moelgaard Andersen [http://community.jboss.org/people/mda_dk] replied to the discussion

"JDBC inside CMT"

To view the discussion, visit: http://community.jboss.org/message/557879#557879

Hi Wolf-Dieter

Thanks for your reply.
The actual setup is somewhat more complex than my example.

I reality my MDB need to use JDBC for queries on a number of tables that are not entities and where it makes no sense to define entity objects for these tables.

The JDBC connection I get from a DS.

My MDB also operates on entity objects, naturally through the entityManager.

Everywhere I read about transactions I run into roughly the same text, following taken from:
 http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction3.html http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Transaction3.html

> You should not invoke any method that might interfere with the  transaction boundaries set by the container. The list of prohibited  methods follows: 
> * 
> .  The commit, *setAutoCommit*, and rollback methods of java.sql.Connection 
> * 
> .  The getUserTransaction method of javax.ejb.EJBContext
> * 
> .  Any method of javax.transaction.UserTransaction

Since I basically work with a MDB with CMT I wonder about the consequences of mixing JDBC with CMT. 

It is not an option to have the MDB's transaction control the completion of the JDBC queries as their completion is a precondition for making the queries on the entity objects.

I've taken the consequence of not finding any satisfying answers as to why it cannot be mixed and put all of my JDBC in a BMT SLSB with AutoCommit = true and where I open and (naturally) close connection, statements and ResultSets.

Again.....nowhere I've been able to find a decent explanation as to why?

Thanks again. Best regards
Mads M Andersen


Reply to this message by going to Community

Start a new discussion in Beginner's Corner at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100818/8b111167/attachment-0001.html 

More information about the jboss-user mailing list