From 3b23a96822eb770f7dce83e2a4592d2c48043e53 Mon Sep 17 00:00:00 2001 From: Sreekanth Vadigi Date: Fri, 21 Aug 2026 22:51:01 +0000 Subject: [PATCH 1/2] Fix duplicate connection property handling Allow URL and Properties inputs to overlap while preserving URL precedence. Signed-off-by: Sreekanth Vadigi --- NEXT_CHANGELOG.md | 1 + .../jdbc/api/impl/DatabricksConnectionContext.java | 9 +++++---- .../api/impl/DatabricksConnectionContextTest.java | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index e12c8875f..f881783d0 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,6 +8,7 @@ - `DatabaseMetaData.getColumns(...)` with a `null` catalog now issues a single `SHOW COLUMNS IN ALL CATALOGS` statement (consistent with `getSchemas`/`getTables`) instead of enumerating every catalog and issuing a per-catalog `SHOW COLUMNS`. Older DBR versions that do not support the syntax transparently fall back to the previous enumerate-and-fan-out behavior. ### Fixed +- Fixed connections failing when the same parameter is provided in both the JDBC URL and the connection properties. - Fixed `IdleConnectionEvictor` thread leak in long-running applications. Driver-side resources (HTTP client, background threads) are now always released when `Connection.close()` is called, even if statement cleanup or server-side session termination fails. - Throw `DatabricksSQLException` instead of an unchecked `ClassCastException` when a complex-type getter (`getArray`, `getStruct`, `getMap`) is called on a column of a different complex type. diff --git a/src/main/java/com/databricks/jdbc/api/impl/DatabricksConnectionContext.java b/src/main/java/com/databricks/jdbc/api/impl/DatabricksConnectionContext.java index dfa4b70f9..38cd85670 100644 --- a/src/main/java/com/databricks/jdbc/api/impl/DatabricksConnectionContext.java +++ b/src/main/java/com/databricks/jdbc/api/impl/DatabricksConnectionContext.java @@ -105,6 +105,7 @@ private DatabricksConnectionContext( /** * Builds a map of properties from the given connection parameter string and properties object. + * Connection URL parameters take precedence over entries in the properties object. * * @param connectionParamString the connection parameter string * @param properties the properties object @@ -113,6 +114,9 @@ private DatabricksConnectionContext( public static ImmutableMap buildPropertiesMap( String connectionParamString, Properties properties) { ImmutableMap.Builder parametersBuilder = ImmutableMap.builder(); + for (Map.Entry entry : properties.entrySet()) { + parametersBuilder.put(entry.getKey().toString().toLowerCase(), entry.getValue().toString()); + } // check if connectionParamString is empty or null if (!isNullOrEmpty(connectionParamString)) { String[] urlParts = connectionParamString.split(DatabricksJdbcConstants.URL_DELIMITER); @@ -128,10 +132,7 @@ public static ImmutableMap buildPropertiesMap( } } } - for (Map.Entry entry : properties.entrySet()) { - parametersBuilder.put(entry.getKey().toString().toLowerCase(), entry.getValue().toString()); - } - return parametersBuilder.build(); + return parametersBuilder.buildKeepingLast(); } static IDatabricksConnectionContext parseWithoutError(String url, Properties properties) { diff --git a/src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionContextTest.java b/src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionContextTest.java index 2d68683de..2518797a4 100644 --- a/src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionContextTest.java +++ b/src/test/java/com/databricks/jdbc/api/impl/DatabricksConnectionContextTest.java @@ -60,6 +60,20 @@ public void testBuildPropertiesMap() { assertEquals("value3", propertiesMap.get("param3")); } + @ParameterizedTest + @CsvSource({"url-value, url-value", "url-value, properties-value"}) + public void testBuildPropertiesMapUrlOverridesProperties( + String urlValue, String propertiesValue) { + Properties properties = new Properties(); + properties.setProperty("HTTPPATH", propertiesValue); + + ImmutableMap propertiesMap = + buildPropertiesMap("httpPath=" + urlValue, properties); + + assertEquals(1, propertiesMap.size()); + assertEquals(urlValue, propertiesMap.get("httppath")); + } + @Test public void testTelemetrySocketTimeoutDefault() throws DatabricksSQLException { DatabricksConnectionContext context = From 3b6bdd3cb993079299ec393e75e811508f709162 Mon Sep 17 00:00:00 2001 From: Sreekanth Vadigi Date: Fri, 21 Aug 2026 22:52:57 +0000 Subject: [PATCH 2/2] Clarify duplicate property precedence Signed-off-by: Sreekanth Vadigi --- NEXT_CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index f881783d0..8e44c82b1 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -8,7 +8,7 @@ - `DatabaseMetaData.getColumns(...)` with a `null` catalog now issues a single `SHOW COLUMNS IN ALL CATALOGS` statement (consistent with `getSchemas`/`getTables`) instead of enumerating every catalog and issuing a per-catalog `SHOW COLUMNS`. Older DBR versions that do not support the syntax transparently fall back to the previous enumerate-and-fan-out behavior. ### Fixed -- Fixed connections failing when the same parameter is provided in both the JDBC URL and the connection properties. +- Fixed connections failing when the same parameter is provided in both the JDBC URL and the connection properties, with the JDBC URL taking precedence. - Fixed `IdleConnectionEvictor` thread leak in long-running applications. Driver-side resources (HTTP client, background threads) are now always released when `Connection.close()` is called, even if statement cleanup or server-side session termination fails. - Throw `DatabricksSQLException` instead of an unchecked `ClassCastException` when a complex-type getter (`getArray`, `getStruct`, `getMap`) is called on a column of a different complex type.