brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.72k stars 2.91k forks source link

Hikari does not handle SQLFeatureNotSupportedException in PoolBase.setupConnection when setting autoCommit #1894

Open Nyefan opened 2 years ago

Nyefan commented 2 years ago

While fixing issue 1116, calls to connection.getAutoCommit() and connection.isReadOnly() were added to gate calls to the associated setters in PoolBase. However, this breaks integration with the mongo-jdbc-driver as getAutoCommit() throws a SQLFeatureNotSupportedException because the driver acts as though autoCommit is always false.

As per the Connection documentation, "if setAutoCommit is called, and the auto-commit mode is not changed, the call is a no-op", so I believe the correct way to handle this would be to remove the gates, but I believe the following would work as well:


try {
  if (connection.getAutoCommit() ~= isAutoCommit) {
    connection.setAutoCommit(isAutocommit);
  }
} catch (SQLFeatureNotSupportedException {
  // pass;
}
radu-almasan commented 1 year ago

The same problem occurs with Pinot's JDBC driver.

jaceksan commented 5 months ago

Any news here? Is there any way how to workaround this issue? Override some methods? How exactly?

Nyefan commented 5 months ago

It looks like the fix was released in v1.1.0 of the mongo-jdbc-driver.

jaceksan commented 5 months ago

We fixed it in Pinot driver. It was merged but not yet released.

https://github.com/apache/pinot/pull/12480