May 16th, 2011, 03:34 PM
How to use Spring 3.x JdbcTemplate with NO transaction?
I need to invoke some sql and it needs to be done outside a transaction. It's being done on a separate thread in a noncritical listener after the db work in my main thread commits.
I'm trying to use a new JdbcTemplate in the child thread, giving its constructor the DataSource that I'm using in my main thread, but there appears to be no way to turn autocommit back on via the new JdbcTemplate I'm using in the child thread. I don't see any properties allowing me to do that.
How can I invoke arbitrary SQL via JdbcTemplate and have it do the work outside a transaction?
May 16th, 2011, 05:56 PM
I think my requirements would be met
- if I could either provide my own connection to the JdbcTemplate, for example, in the constructor,
- if there were a property or set of properties that I could set that instructed the JdbcTemplate to obtain a new connection from its DataSource, turn off autocommit and/or not enlist the work in a transaction, or
- if there were another framework class like JdbcTemplate but that didn't do any transaction management but provided the same convenient methods as JdbcTemplate.
May 18th, 2011, 07:32 AM
Uh, great. So if I download pirated DVDs, I can use JdbcTemplate with no transaction? Wow, I would have never guessed.