[jboss-user] [JCA/JBoss] - Re: autocommit question

weston.price@jboss.com do-not-reply at jboss.com
Wed Feb 14 13:21:01 EST 2007

This is correct. 

The <local-tx-datasource> will automatically set the auto commit value of  the connection to false depending upon the context of the global transaction. Typically, there is no reason for you to use this datasource *and* set the auto commit value yourself. If you want to use this datasource outside of the context of a global transaction you can simply aquire the connection and set the value yourself. Note, this is not really the way this data source is intended for use. As a result, you have a few options:

1) Use the <no-tx-datasource>. Use of this datasource will put the responsiblity of the transaction on you. After acquiring the DataSource you will want to do the setAutoCommit(false), do your JDBC work, and then commit. This type of datasource funtions much like a non-managed datasource running outside of the application server though you still get pooling, can leverage security etc. With you particular config, you can do this simply by renaming the 

  |    <local-tx-datasource>
  |     to
  |    <no-tx-datasource>

and remove the auto commit property. 

2) Start a global transaction in your WebApplication via the UserTransaction object bound into JNDI to scope the work you want your JDBC connection to be enlisted in. See the JTA spec for examples.

3) Use EJB(X) and leverage CMT and declarative transaction management to do all of this for you. 

More on datasource configuration can be found here: 


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016513#4016513

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016513

More information about the jboss-user mailing list