From c21dae6d3a0bae249f36c0103d7abd0256b71ec4 Mon Sep 17 00:00:00 2001 From: mdb Date: Mon, 30 Jul 2007 18:54:51 +0000 Subject: [PATCH] Restore our auto-commit settings before releasing the connection back to the provider. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2147 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/jdbc/SimpleRepository.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/java/com/samskivert/jdbc/SimpleRepository.java b/src/java/com/samskivert/jdbc/SimpleRepository.java index 71fda3d1..50893dd0 100644 --- a/src/java/com/samskivert/jdbc/SimpleRepository.java +++ b/src/java/com/samskivert/jdbc/SimpleRepository.java @@ -139,6 +139,7 @@ public class SimpleRepository extends Repository V rv = null; boolean supportsTransactions = false; boolean attemptedOperation = false; + Boolean oldAutoCommit = null; // check our pre-condition if (_precond != null && !_precond.validate(_dbident, op)) { @@ -163,7 +164,10 @@ public class SimpleRepository extends Repository } // turn off auto-commit - conn.setAutoCommit(false); + if (supportsTransactions) { + oldAutoCommit = conn.getAutoCommit(); + conn.setAutoCommit(false); + } // let derived classes do any got-connection processing gotConnection(conn); @@ -240,6 +244,14 @@ public class SimpleRepository extends Repository } finally { if (conn != null) { + // restore our auto-commit settings + if (oldAutoCommit != null) { + try { + conn.setAutoCommit(oldAutoCommit); + } catch (SQLException sace) { + Log.warning("Unable to restore auto-commit [err=" + sace + "]."); + } + } // release the database connection _provider.releaseConnection(_dbident, readOnly, conn); }