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
This commit is contained in:
samskivert
2008-09-26 00:04:16 +00:00
parent 6a2b870cf9
commit 2e93d12396
@@ -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) {