Skip to content

Commit

Permalink
Enabled autocommit by default for pooled Oracle connections
Browse files Browse the repository at this point in the history
The JDBC specification says that connections are expected to be in
autocommit mode by default. Oracle's UCP connection pool doesn't reset
the autocommit state when reusing an already created connection.
So we explicitly enable autocommit for any connection returned from the
pool to match the JDBC specification.
  • Loading branch information
hashhar committed Jul 15, 2021
1 parent ab9f02d commit 3a30d76
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public OraclePoolConnectionFactory(
public Connection openConnection(ConnectorSession session)
throws SQLException
{
return dataSource.getConnection();
Connection connection = dataSource.getConnection();
// Oracle's pool doesn't reset autocommit state of connections when reusing them so we explicitly enable
// autocommit by default to match the JDBC specification.
connection.setAutoCommit(true);
return connection;
}
}

0 comments on commit 3a30d76

Please sign in to comment.