From 2e93d1239621cda2e9ac45bd1017416d2b9b2995 Mon Sep 17 00:00:00 2001 From: samskivert Date: Fri, 26 Sep 2008 00:04:16 +0000 Subject: [PATCH] Allow the default auto-commit settings for a connection to be configured along with the other JDBC properties. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2451 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../samskivert/jdbc/StaticConnectionProvider.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java index f25262cb..a239bc32 100644 --- a/src/java/com/samskivert/jdbc/StaticConnectionProvider.java +++ b/src/java/com/samskivert/jdbc/StaticConnectionProvider.java @@ -126,6 +126,7 @@ public class StaticConnectionProvider implements ConnectionProvider String username = requireProp(props, "username", err); err = "No driver password specified [ident=" + ident + "]."; String password = requireProp(props, "password", err); + String autoCommit = props.getProperty("autocommit"); // if this is a read-only connection, we cache connections by username+url+readOnly to // avoid making more that one connection to a particular database server @@ -137,6 +138,18 @@ public class StaticConnectionProvider implements ConnectionProvider conmap.key = key; conmap.connection = openConnection(driver, url, username, password); + // if we were requested to configure auto-commit, then do so + if (autoCommit != null) { + try { + conmap.connection.setAutoCommit(Boolean.valueOf(autoCommit)); + } catch (SQLException sqe) { + closeConnection(ident, conmap.connection); + err = "Failed to configure auto-commit [key=" + key + + ", ident=" + ident + ", autoCommit=" + autoCommit + "]."; + throw new PersistenceException(err, sqe); + } + } + // make the connection read-only to let the JDBC driver know that it can and should // use the read-only mirror(s) if (readOnly) {