Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/clickhouse-docs/jdbc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ as is to the driver. Driver has some own properties that aren't part of the clie
**Driver properties**:
| Property | Default | Description |
|----------------------------------|---------|----------------------------------------------------------------|
| `disable_frameworks_detection` | `true` | Disable frameworks detection for User-Agent |
| `disable_frameworks_detection` | `false` | Disable frameworks detection for User-Agent |
| `jdbc_ignore_unsupported_values` | `false` | Suppresses `SQLFeatureNotSupportedException` where is doesn't affect the driver work |
| `clickhouse.jdbc.v1` | `false` | Use older JDBC implementation instead of new JDBC |
| `default_query_settings` | `null` | Allows passing of default query settings with query operations |
Expand Down
5 changes: 5 additions & 0 deletions history/latest/3218.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- **[jdbc-v2]** The documented driver property `disable_frameworks_detection` is now a driver property and is no
longer forwarded to the client, so setting it no longer fails the connection with
`Unknown and unmapped config properties`. The property is now also read from the connection URL, not only from the
`Properties` argument. The documented default is corrected to `false`.
(https://github.com/ClickHouse/clickhouse-java/issues/3218)
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public enum DriverProperties {
*/
METADATA_USE_SHOW_STATEMENTS("jdbc_metadata_use_show_statements", String.valueOf(Boolean.TRUE)),

/**
* Disables detection of application frameworks (for example Apache Spark) for the {@code User-Agent} header.
* Default: false
*/
DISABLE_FRAMEWORKS_DETECTION("disable_frameworks_detection", String.valueOf(Boolean.FALSE)),

;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public Map<String, Class<?>> getTypeMap() {
*/
public JdbcConfiguration(String url, Properties info) throws SQLException {
final Properties props = info == null ? new Properties() : info;
this.disableFrameworkDetection = Boolean.parseBoolean(props.getProperty("disable_frameworks_detection", "false"));
this.clientProperties = new HashMap<>();
this.driverProperties = new HashMap<>();

Expand All @@ -131,6 +130,7 @@ public JdbcConfiguration(String url, Properties info) throws SQLException {
Map<String, String> urlProperties = parseUrl(url);
String tmpConnectionUrl = urlProperties.remove(PARSE_URL_CONN_URL_PROP);
buildFinalProperties(urlProperties, props);
this.disableFrameworkDetection = isSet(DriverProperties.DISABLE_FRAMEWORKS_DETECTION);

// after initializing all properties - set final connection URL
boolean useSSLInfo = Boolean.parseBoolean(props.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,39 @@ public void testSSLModeInvalidValue() {
() -> new JdbcConfiguration("jdbc:clickhouse://localhost:8123/?ssl_mode=insecure", new Properties()));
}

@DataProvider(name = "disableFrameworksDetectionValues")
public Object[][] disableFrameworksDetectionValues() {
return new Object[][] {
{"", null, false},
{"", "true", true},
{"", "false", false},
{"?disable_frameworks_detection=true", null, true},
{"?disable_frameworks_detection=false", null, false},
{"?disable_frameworks_detection=true", "false", true},
};
}

@Test(dataProvider = "disableFrameworksDetectionValues")
public void testDisableFrameworksDetectionIsDriverProperty(String urlParams, String propertyValue,
boolean expected) throws Exception {
Properties properties = new Properties();
if (propertyValue != null) {
properties.setProperty(DriverProperties.DISABLE_FRAMEWORKS_DETECTION.getKey(), propertyValue);
}
JdbcConfiguration configuration = new JdbcConfiguration("jdbc:clickhouse://localhost:8123/" + urlParams,
properties);
assertEquals(configuration.isDisableFrameworkDetection(), expected);
Assert.assertFalse(configuration.getClientProperties()
.containsKey(DriverProperties.DISABLE_FRAMEWORKS_DETECTION.getKey()));
}

@Test
public void testUnknownPropertyForwardedToClientProperties() throws Exception {
JdbcConfiguration configuration = new JdbcConfiguration(
"jdbc:clickhouse://localhost:8123/?unknown_test_property=1", new Properties());
assertEquals(configuration.getClientProperties().get("unknown_test_property"), "1");
}

@Test
public void testSSLCipherSuitesForwardedToClientProperties() throws Exception {
String cipherSuites = "TLS_AES_256_GCM_SHA384,TLS_AES_128_GCM_SHA256";
Expand Down
Loading