Skip to content

Make Connection.setReadOnly a no-op instead of throwing#1523

Merged
vikrantpuppala merged 1 commit into
mainfrom
fix/setreadonly-noop
Jul 2, 2026
Merged

Make Connection.setReadOnly a no-op instead of throwing#1523
vikrantpuppala merged 1 commit into
mainfrom
fix/setreadonly-noop

Conversation

@vikrantpuppala

Copy link
Copy Markdown
Collaborator

Summary

Connection.setReadOnly(true) threw DatabricksSQLFeatureNotSupportedException, which breaks JDBC clients that call setReadOnly(true) during connection initialization — e.g. the Trino/Starburst GenericJDBC connector, HikariCP, and DBCP connection pools. This was reported via an internal support thread for a Starburst GenericJDBC integration.

Per the JDBC spec, setReadOnly is a hint used to enable database optimizations; a driver that does not enforce a connection-level read-only mode is permitted to ignore it. The Databricks backend does not enforce read-only mode, so throwing here is non-conformant.

Fix

  • setReadOnly(true) is now a no-op (it still validates the connection is open, matching the prior behavior of throwExceptionIfConnectionIsClosed()).
  • isReadOnly() continues to return false, since the hint is not actually enforced — this remains accurate.

Test plan

  • Updated DatabricksConnectionTest#testReadOnlyAndAbort:
    • setReadOnly(false) — no throw (unchanged)
    • setReadOnly(true) — now asserts no throw (was previously asserting DatabricksSQLFeatureNotSupportedException)
    • isReadOnly() still returns false
  • Ran the full DatabricksConnectionTest class — all pass.
  • Closed-connection behavior preserved: isReadOnly() on a closed connection still throws DatabricksSQLException (existing test at line 353).

NO_CHANGELOG=false

Connection.setReadOnly(true) threw DatabricksSQLFeatureNotSupportedException,
which broke JDBC clients that call it during connection initialization
(e.g. Trino/Starburst GenericJDBC connector, HikariCP, DBCP).

Per the JDBC spec, setReadOnly is a hint used to enable database
optimizations and may be ignored by drivers that do not enforce a
connection-level read-only mode. The Databricks backend does not enforce
read-only mode, so setReadOnly is now a no-op and isReadOnly() continues
to report false since the hint is not enforced.

Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
@vikrantpuppala vikrantpuppala merged commit 8d9333f into main Jul 2, 2026
17 checks passed
@vikrantpuppala vikrantpuppala deleted the fix/setreadonly-noop branch July 2, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants