No auto-commit for tx connections.

This commit is contained in:
Michael Bayne
2014-10-01 14:42:50 -07:00
parent 1a822593fb
commit d83760bb39
2 changed files with 22 additions and 15 deletions
@@ -41,19 +41,7 @@ public class DataSourceConnectionProvider implements ConnectionProvider
public Connection getConnection (String ident, boolean readOnly) public Connection getConnection (String ident, boolean readOnly)
throws PersistenceException throws PersistenceException
{ {
try { return getConnection(ident, readOnly, null);
Connection conn;
if (readOnly) {
conn = _readSource.getConnection();
conn.setReadOnly(true);
} else {
conn = _writeSource.getConnection();
}
return conn;
} catch (SQLException sqe) {
throw new PersistenceException(sqe);
}
} }
// from ConnectionProvider // from ConnectionProvider
@@ -83,7 +71,7 @@ public class DataSourceConnectionProvider implements ConnectionProvider
public Connection getTxConnection (String ident) throws PersistenceException public Connection getTxConnection (String ident) throws PersistenceException
{ {
// our connections are pooled, so we can just get them normally // our connections are pooled, so we can just get them normally
return getConnection(ident, false); return getConnection(ident, false, false);
} }
// from ConnectionProvider // from ConnectionProvider
@@ -112,6 +100,25 @@ public class DataSourceConnectionProvider implements ConnectionProvider
// nothing doing, the caller has to shutdown the datasources // nothing doing, the caller has to shutdown the datasources
} }
protected Connection getConnection (String ident, boolean readOnly, Boolean autoCommit)
throws PersistenceException
{
try {
Connection conn;
if (readOnly) {
conn = _readSource.getConnection();
conn.setReadOnly(true);
} else {
conn = _writeSource.getConnection();
}
if (autoCommit != null) conn.setAutoCommit(autoCommit);
return conn;
} catch (SQLException sqe) {
throw new PersistenceException(sqe);
}
}
protected String _url; protected String _url;
protected DataSource _readSource, _writeSource; protected DataSource _readSource, _writeSource;
} }
@@ -130,7 +130,7 @@ public class StaticConnectionProvider implements ConnectionProvider
// from ConnectionProvider // from ConnectionProvider
public Connection getTxConnection (String ident) throws PersistenceException public Connection getTxConnection (String ident) throws PersistenceException
{ {
return getMapping(ident, false).openConnection(ident, null); return getMapping(ident, false).openConnection(ident, false);
} }
// from ConnectionProvider // from ConnectionProvider