Make Connection.setReadOnly a no-op instead of throwing#1523
Merged
Conversation
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>
gopalldb
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Connection.setReadOnly(true)threwDatabricksSQLFeatureNotSupportedException, which breaks JDBC clients that callsetReadOnly(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,
setReadOnlyis 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 ofthrowExceptionIfConnectionIsClosed()).isReadOnly()continues to returnfalse, since the hint is not actually enforced — this remains accurate.Test plan
DatabricksConnectionTest#testReadOnlyAndAbort:setReadOnly(false)— no throw (unchanged)setReadOnly(true)— now asserts no throw (was previously assertingDatabricksSQLFeatureNotSupportedException)isReadOnly()still returnsfalseDatabricksConnectionTestclass — all pass.isReadOnly()on a closed connection still throwsDatabricksSQLException(existing test at line 353).NO_CHANGELOG=false