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

Wolf-Dieter Fink do-not-reply at jboss.com
Wed Aug 18 09:10:42 EDT 2010


Wolf-Dieter Fink [http://community.jboss.org/people/wdfink] replied to the discussion

"JDBC inside CMT"

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

--------------------------------------------------------------
Ok,
if you are using a DataSource and set explicit autocommit the result after return connection into the pool might be surprisingly because the connection will be reused.
We have some trouble in the past with 'non standard' solutions, it will become difficult in case of app-server upgrade or code changes.


But if I understand your scenario correct you do only some SELECTs vie JDBC, right?
If so, there is no necessity for autocommit.

I use JDBC also within CMT beans, I'll leave the connection unchanged and delegate the rollback to the container.
If a RuntimeException is thrown the container rollback for you.
If an Exception should thrown I force the rollback via <context>.setRollbackOnly()

So I prefere a transactional MDB and throw an Exception to rollback or delegate to a SLSB with Tx=RequiresNew.

Remember that all entity access must have a transaction, if no available the container will open one explicit (this can cause less performance)

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/557915#557915]

Start a new discussion in Beginner's Corner at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2075]

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


More information about the jboss-user mailing list