-
1. Re: Explicit commit on connection failing
weston.price Oct 4, 2006 12:08 PM (in response to vijay_kirti)Using the no-tx-datasource means just that, no transactions at the driver level.
To do what you want you need to get the connection, set autocommit to false, do your JDBC stuff, and then commit.
Note, your Spring/Hib transaction configuration are JTA transactions, these are different than JDBC level transactions. -
2. Re: Explicit commit on connection failing
weston.price Oct 4, 2006 12:14 PM (in response to vijay_kirti)Note, I should have mentioned that you don't have to do what I described above. You can very well not modify the autocommit of the underlying connection. However, what this means is that every statement you run will be a seperate JDBC transaction; this is what autocommit means.
-
3. Re: Explicit commit on connection failing
vijay_kirti Oct 5, 2006 4:02 AM (in response to vijay_kirti)Thanks for replying,
Does this mean if I have to do batch commit then I have to grab connection and set its auto commit to false. Do I need to set the connection autocommit back to yes once finished?
For WebSphere and WebLogic, connection obtained from DataSource seems to have autocommit false. Is there any way to get the same behaviour for JBoss without code changes?
Thanks,
Vijay -
4. Re: Explicit commit on connection failing
weston.price Oct 18, 2006 12:39 AM (in response to vijay_kirti)
Does this mean if I have to do batch commit then I have to grab connection and set its auto commit to false. Do I need to set the connection autocommit back to yes once finished?
No, you will want to take a look at this:
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJCALazyAutoCommit
For WebSphere and WebLogic, connection obtained from DataSource seems to have autocommit false. Is there any way to get the same behaviour for JBoss without code changes?
WebSpere and Weblogic, AFAIK, do not have the notion of a NoTx DataSource. Local transactions (ie AutoCommit == false) is on all the time. You can use a LocalTx datasource but you will be required to remove the setAutoCommit(), commit(), rollback() logic from your code as this role would be given over to JBoss.