From c4f6d934f4f31d03f18d28b58b7e9cc5ff786cc2 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Tue, 9 Sep 2025 09:20:10 -0700 Subject: [PATCH 1/3] Fixed version methods to reflect major and minor version from semver. --- .../client/internal/SmallTests.java | 62 +------------------ .../com/clickhouse/jdbc/ConnectionImpl.java | 2 +- .../main/java/com/clickhouse/jdbc/Driver.java | 49 ++++++++------- .../jdbc/internal/JdbcConfiguration.java | 2 +- .../jdbc/metadata/DatabaseMetaDataImpl.java | 6 +- .../java/com/clickhouse/jdbc/DriverTest.java | 39 +++++++++--- 6 files changed, 66 insertions(+), 94 deletions(-) diff --git a/client-v2/src/test/java/com/clickhouse/client/internal/SmallTests.java b/client-v2/src/test/java/com/clickhouse/client/internal/SmallTests.java index ff42c0ced..42be10846 100644 --- a/client-v2/src/test/java/com/clickhouse/client/internal/SmallTests.java +++ b/client-v2/src/test/java/com/clickhouse/client/internal/SmallTests.java @@ -1,64 +1,8 @@ package com.clickhouse.client.internal; -import com.clickhouse.client.api.ClientConfigProperties; -import com.clickhouse.client.api.data_formats.internal.ProcessParser; -import com.clickhouse.client.api.metrics.OperationMetrics; -import com.clickhouse.client.api.metrics.ServerMetrics; -import org.testng.Assert; -import org.testng.annotations.Test; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.time.ZoneId; -import java.time.ZonedDateTime; - +/** + * Tests playground + */ public class SmallTests { - - @Test - public void testSummaryParser() { - OperationMetrics operationMetrics = new OperationMetrics(null); - String summary = createSummary(10, 200, 0, 0, 5, 6000); - ProcessParser.parseSummary(summary, operationMetrics); - - Assert.assertEquals(operationMetrics.getMetric(ServerMetrics.NUM_ROWS_READ).getLong(), 10); - Assert.assertEquals(operationMetrics.getMetric(ServerMetrics.NUM_BYTES_READ).getLong(), 200); - - } - - public static String createSummary(int readRows, int readBytes, int writtenRows, - int writtenBytes, int totalRowsToRead, long elapsedNs) { - return "{\"read_rows\":\"" + readRows + "\"," + - "\"read_bytes\":\"" + readBytes + "\"," + - "\"written_rows\":\"" + writtenRows + "\"," + - "\"written_bytes\":\"" + writtenBytes + "\"," + - "\"total_rows_to_read\":\"" + totalRowsToRead + "\"," + - "\"elapsed_ns\":\"" + elapsedNs + "\"}"; - - } - - @Test - public void testTimezoneConvertion() { - ZonedDateTime dt = ZonedDateTime.now(); - System.out.println(" now: " + dt); - ZonedDateTime utcSameInstantDt = dt.withZoneSameInstant(ZoneId.of("UTC")); - System.out.println("withZoneSameInstant: " + utcSameInstantDt); - ZonedDateTime utcSameLocalDt = dt.withZoneSameLocal(ZoneId.of("UTC")); - System.out.println("withZoneSameLocal: " + utcSameLocalDt); - } - - @Test - public void testGenConfigParameters() { - System.out.println("

Default: `none`
Enum: `none`
Key: `none` " - - - ); - for (ClientConfigProperties p : ClientConfigProperties.values()) { - String defaultValue = p.getDefaultValue() == null ? "-" : "`" + p.getDefaultValue() + "`"; - System.out.println("

Default: " +defaultValue + "
Enum: `ClientConfigProperties." + p.name() + "`
Key: `" + p.getKey() +"` " - - - ); - } - } } diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java index 5a8b073e0..668d9d3c9 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java @@ -80,7 +80,7 @@ public ConnectionImpl(String url, Properties info) throws SQLException { this.appName = ""; this.readOnly = false; this.holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT; - String clientName = "ClickHouse JDBC Driver V2/" + Driver.driverVersion; + String clientName = "ClickHouse JDBC Driver V2/" + Driver.getLibraryVersion(); Map clientProperties = config.getClientProperties(); if (clientProperties.get(ClientConfigProperties.CLIENT_NAME.getKey()) != null) { diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java index f78bb4297..59291c3d4 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java @@ -26,9 +26,10 @@ */ public class Driver implements java.sql.Driver { private static final Logger log = LoggerFactory.getLogger(Driver.class); - public static final String driverVersion; - public static final int majorVersion; - public static final int minorVersion; + + private static final String driverVersion; + private static final int majorVersion; + private static final int minorVersion; private final DataSourceImpl dataSource; public static String frameworksDetected = null; @@ -66,25 +67,10 @@ public static String getFrameworksDetected() { driverVersion = ClickHouseClientOption.readVersionFromResource("jdbc-v2-version.properties"); log.debug("ClickHouse JDBC driver version: {}", driverVersion); - int tmpMajorVersion; - int tmpMinorVersion; - - try { - Matcher m = Pattern.compile("(\\d+)(\\.\\d+)(\\.\\d+)").matcher(driverVersion); - if (m.find()) { - tmpMajorVersion = Integer.parseInt(m.group(1)); - tmpMinorVersion = Integer.parseInt(m.group(2).substring(1)); - } else { - tmpMajorVersion = 0; - tmpMinorVersion = 0; - } - } catch (Exception e) { - tmpMajorVersion = 0; - tmpMinorVersion = 0; - } + int[] versions = parseVersion(driverVersion); - majorVersion = tmpMajorVersion; - minorVersion = tmpMinorVersion; + majorVersion = versions[0]; + minorVersion = versions[1]; //Load the driver //load(); //Commented out to avoid loading the driver multiple times, because we're referenced in V1 @@ -153,6 +139,7 @@ public int getMinorVersion() { @Override public boolean jdbcCompliant() { + // Mainly because of not supported Transactions. return false; } @@ -165,5 +152,25 @@ public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedE throw new SQLFeatureNotSupportedException("Method not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED); } + public static String getLibraryVersion() { + return driverVersion; + } + private static final Driver INSTANCE = new Driver(); + + public static int[] parseVersion(String version) { + if (version != null) { + final Pattern pattern = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)"); + + Matcher matcher = pattern.matcher(version); + if (matcher.find()) { + short major = Short.parseShort(matcher.group(1)); + short minor = Short.parseShort(matcher.group(2)); + int patch = Integer.parseInt(matcher.group(3)); + int majorVersion = (major << 16) | minor; + return new int[]{majorVersion, patch}; + } + } + return new int[] { 0, 0 }; + } } diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java index 73de6bbfc..f963b8f93 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java @@ -303,7 +303,7 @@ public void updateUserClient(String clientName, Client client) { public static String getDefaultClientName() { StringBuilder jdbcName = new StringBuilder(); jdbcName.append(Driver.DRIVER_CLIENT_NAME) - .append(Driver.driverVersion); + .append(Driver.getLibraryVersion()); return jdbcName.toString(); } diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java index a42429548..f656873b8 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/DatabaseMetaDataImpl.java @@ -8,10 +8,9 @@ import com.clickhouse.jdbc.Driver; import com.clickhouse.jdbc.DriverProperties; import com.clickhouse.jdbc.JdbcV2Wrapper; -import com.clickhouse.jdbc.ResultSetImpl; +import com.clickhouse.jdbc.internal.DetachedResultSet; import com.clickhouse.jdbc.internal.ExceptionUtils; import com.clickhouse.jdbc.internal.JdbcUtils; -import com.clickhouse.jdbc.internal.DetachedResultSet; import com.clickhouse.logging.Logger; import com.clickhouse.logging.LoggerFactory; @@ -29,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.function.Consumer; -import java.util.function.Function; public class DatabaseMetaDataImpl implements java.sql.DatabaseMetaData, JdbcV2Wrapper { private static final Logger log = LoggerFactory.getLogger(DatabaseMetaDataImpl.class); @@ -132,7 +130,7 @@ public String getDriverName() throws SQLException { @Override public String getDriverVersion() throws SQLException { - return Driver.driverVersion; + return Driver.getLibraryVersion(); } @Override diff --git a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java index 00a29430d..325b24968 100644 --- a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java +++ b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java @@ -2,11 +2,17 @@ import com.clickhouse.client.api.ClientConfigProperties; import org.testng.Assert; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static org.testng.AssertJUnit.assertTrue; +import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; public class DriverTest extends JdbcIntegrationTest { @@ -46,10 +52,11 @@ public void testAcceptsURL() { } } - @Test (enabled = false) //Disabled for now because it's not implemented + @Test(groups = {"integration"}) public void testGetPropertyInfo() { try { Driver driver = new Driver(); + driver.getPropertyInfo(getEndpointString(), new Properties()); Assert.assertEquals(driver.getPropertyInfo(getEndpointString(), new Properties()).length, 7); Properties sample = new Properties(); sample.setProperty("testing", "true"); @@ -59,16 +66,32 @@ public void testGetPropertyInfo() { } } - @Test(groups = { "integration" }) - public void testGetMajorVersion() { + @Test(groups = {"integration"}) + public void testGetDriverVersion() { Driver driver = new Driver(); - Assert.assertEquals(driver.getMajorVersion(), 0); + assertTrue(driver.getMajorVersion() > 0); + assertTrue(driver.getMinorVersion() > -1); } - @Test(groups = { "integration" }) - public void testGetMinorVersion() { - Driver driver = new Driver(); - Assert.assertEquals(driver.getMinorVersion(), 9); + @Test(groups = {"integration"}, dataProvider = "testParsingDriverVersionDP") + public void testParsingDriverVersion(String version, int expectedMajor, int expectedMinor) { + int[] versions = Driver.parseVersion(version); + Assert.assertEquals(versions, new int[] { expectedMajor, expectedMinor }); + } + + @DataProvider(name = "testParsingDriverVersionDP") + public static Object[][] testParsingDriverVersionDP() { + return new Object[][]{ + {"", 0, 0}, + {null, 0, 0}, + {"0.9.1", 0x09, 0x01}, + {"1.0.0", 0x010000, 0}, + {"1.0.1", 0x010000, 1}, + {"1.1.1", 0x010001, 1}, + {"1.2.1", 0x010002, 1}, + {"5000.20.1", 0x13880014, 1}, + {"2.1.1", 0x020001, 1}, + }; } @Test(groups = { "integration" }) From 24925bbfcf39d5e3977f7911e0d52905b75b1768 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Fri, 19 Sep 2025 18:36:18 -0700 Subject: [PATCH 2/3] fixed Driver issues with USE_TIME_ZONE. Added more test --- .../clickhouse/jdbc/ClickHouseDriverTest.java | 19 ++++--- .../com/clickhouse/client/api/Client.java | 2 + .../com/clickhouse/jdbc/ConnectionImpl.java | 1 - .../main/java/com/clickhouse/jdbc/Driver.java | 4 +- .../jdbc/internal/JdbcConfiguration.java | 18 +++++-- .../com/clickhouse/jdbc/ConnectionTest.java | 11 +++- .../java/com/clickhouse/jdbc/DriverTest.java | 51 +++++++++++++++---- 7 files changed, 81 insertions(+), 25 deletions(-) diff --git a/clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseDriverTest.java b/clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseDriverTest.java index 52fa57c4b..bc6221e58 100644 --- a/clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseDriverTest.java +++ b/clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseDriverTest.java @@ -1,16 +1,13 @@ package com.clickhouse.jdbc; -import java.sql.Connection; -import java.sql.SQLException; - import com.clickhouse.client.ClickHouseProtocol; - import com.clickhouse.client.ClickHouseServerForTest; -import com.clickhouse.client.config.ClickHouseDefaults; -import com.clickhouse.jdbc.internal.ClickHouseJdbcUrlParser; import org.testng.Assert; import org.testng.annotations.Test; +import java.sql.Connection; +import java.sql.SQLException; + public class ClickHouseDriverTest extends JdbcIntegrationTest { @Test(groups = "integration") public void testAcceptUrl() throws SQLException { @@ -24,13 +21,21 @@ public void testAcceptUrl() throws SQLException { @Test(groups = "integration") public void testConnect() throws SQLException { - if (isCloud()) return; //TODO: testConnect - Revisit, see: https://github.com/ClickHouse/clickhouse-java/issues/1747 + if (isCloud()) { + return; // + } + System.setProperty("clickhouse.jdbc.v1","true"); String address = getServerAddress(ClickHouseProtocol.HTTP, true); ClickHouseDriver driver = new ClickHouseDriver(); Connection conn = driver.connect("jdbc:clickhouse://default:" + ClickHouseServerForTest.getPassword() + "@" + address, null); conn.close(); + System.setProperty("clickhouse.jdbc.v1","false"); + ClickHouseDriver driver2 = new ClickHouseDriver(); + Connection conn2 = driver2.connect("jdbc:clickhouse://default:" + ClickHouseServerForTest.getPassword() + "@" + address, null); + conn2.close(); } + @Test(groups = "integration") public void testV2Driver() { System.setProperty("clickhouse.jdbc.v1","false"); diff --git a/client-v2/src/main/java/com/clickhouse/client/api/Client.java b/client-v2/src/main/java/com/clickhouse/client/api/Client.java index 089ec4282..0ddfe5fbe 100644 --- a/client-v2/src/main/java/com/clickhouse/client/api/Client.java +++ b/client-v2/src/main/java/com/clickhouse/client/api/Client.java @@ -766,6 +766,8 @@ public Builder useServerTimeZone(boolean useServerTimeZone) { */ public Builder useTimeZone(String timeZone) { this.configuration.put(ClientConfigProperties.USE_TIMEZONE.getKey(), timeZone); + // switch using server timezone to false + this.configuration.put(ClientConfigProperties.USE_SERVER_TIMEZONE.getKey(), String.valueOf(Boolean.FALSE)); return this; } diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java index 668d9d3c9..40611d191 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java @@ -36,7 +36,6 @@ import java.sql.Struct; import java.time.Duration; import java.time.temporal.ChronoUnit; -import java.util.Arrays; import java.util.Calendar; import java.util.Collections; import java.util.HashSet; diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java index 59291c3d4..ed00fb650 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/Driver.java @@ -164,8 +164,8 @@ public static int[] parseVersion(String version) { Matcher matcher = pattern.matcher(version); if (matcher.find()) { - short major = Short.parseShort(matcher.group(1)); - short minor = Short.parseShort(matcher.group(2)); + int major = Integer.parseInt(matcher.group(1)); + int minor = Integer.parseInt(matcher.group(2)); int patch = Integer.parseInt(matcher.group(3)); int majorVersion = (major << 16) | minor; return new int[]{majorVersion, patch}; diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java index 4a7951573..fe601e51f 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java @@ -7,6 +7,8 @@ import com.clickhouse.jdbc.Driver; import com.clickhouse.jdbc.DriverProperties; import com.google.common.collect.ImmutableMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -24,6 +26,7 @@ import java.util.stream.Collectors; public class JdbcConfiguration { + public static final Logger LOG = LoggerFactory.getLogger(JdbcConfiguration.class); private static final String PREFIX_CLICKHOUSE = "jdbc:clickhouse:"; private static final String PREFIX_CLICKHOUSE_SHORT = "jdbc:ch:"; @@ -61,19 +64,20 @@ public boolean isIgnoreUnsupportedRequests() { * @param info - Driver and Client properties. */ public JdbcConfiguration(String url, Properties info) throws SQLException { - this.disableFrameworkDetection = info != null && Boolean.parseBoolean(info.getProperty("disable_frameworks_detection", "false")); + 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<>(); Map urlProperties = parseUrl(url); String tmpConnectionUrl = urlProperties.remove(PARSE_URL_CONN_URL_PROP); - initProperties(urlProperties, info); + initProperties(urlProperties, props); // after initializing all properties - set final connection URL - boolean useSSLInfo = Boolean.parseBoolean(info.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false")); + boolean useSSLInfo = Boolean.parseBoolean(props.getProperty(DriverProperties.SECURE_CONNECTION.getKey(), "false")); boolean useSSLUrlProperties = Boolean.parseBoolean(urlProperties.getOrDefault(DriverProperties.SECURE_CONNECTION.getKey(), "false")); boolean useSSL = useSSLInfo || useSSLUrlProperties; - String bearerToken = info.getProperty(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), null); + String bearerToken = props.getProperty(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), null); if (bearerToken != null) { clientProperties.put(ClientConfigProperties.BEARERTOKEN_AUTH.getKey(), bearerToken); } @@ -233,6 +237,12 @@ private void initProperties(Map urlProperties, Properties provid props.putAll(urlProperties); + if (props.containsKey(ClientConfigProperties.USE_TIMEZONE.getKey())) { + if (!props.containsKey(ClientConfigProperties.USE_SERVER_TIMEZONE.getKey())) { + props.put(ClientConfigProperties.USE_SERVER_TIMEZONE.getKey(), String.valueOf(Boolean.FALSE)); + } + } + // Process all properties Map propertyInfos = new HashMap<>(); diff --git a/jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java b/jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java index d9287cee7..37b5dd1b6 100644 --- a/jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java +++ b/jdbc-v2/src/test/java/com/clickhouse/jdbc/ConnectionTest.java @@ -39,7 +39,6 @@ import java.util.Arrays; import java.util.Base64; import java.util.Collections; -import java.util.List; import java.util.Properties; import java.util.UUID; import java.util.concurrent.ExecutorService; @@ -962,4 +961,14 @@ public void testClientInfoProperties() throws Exception { assertNull(conn.getClientInfo("unknown")); } } + + @Test(groups = {"integration"}) + public void testUseUserTimeZone() throws Exception { + Properties props = new Properties(); + props.put(ClientConfigProperties.USE_TIMEZONE.getKey(), "America/New_York"); + try (Connection conn = getJdbcConnection(props)) { + // + } + + } } diff --git a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java index 325b24968..fa8173b37 100644 --- a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java +++ b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java @@ -6,13 +6,13 @@ import org.testng.annotations.Test; import java.sql.DriverManager; +import java.sql.DriverPropertyInfo; import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import static org.testng.AssertJUnit.assertTrue; -import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; public class DriverTest extends JdbcIntegrationTest { @@ -52,20 +52,51 @@ public void testAcceptsURL() { } } - @Test(groups = {"integration"}) - public void testGetPropertyInfo() { + @Test(groups = {"integration"}, dataProvider = "testGetPropertyInfoDP") + public void testGetPropertyInfo(String url, Properties props, Map checkProperties) { + final Map checkPropertiesCopy = new HashMap<>(checkProperties); try { Driver driver = new Driver(); - driver.getPropertyInfo(getEndpointString(), new Properties()); - Assert.assertEquals(driver.getPropertyInfo(getEndpointString(), new Properties()).length, 7); - Properties sample = new Properties(); - sample.setProperty("testing", "true"); - Assert.assertEquals(driver.getPropertyInfo(getEndpointString(), sample).length, 7); + DriverPropertyInfo[] properties = driver.getPropertyInfo(url, props); + + for (DriverPropertyInfo property : properties) { + Object expectedValue = checkPropertiesCopy.remove(property.name); + if (expectedValue != null) { + Assert.assertEquals(property.value, expectedValue); + } else { + for (DriverProperties driverProp : DriverProperties.values()) { + if (driverProp.getKey().equalsIgnoreCase(property.name)) { + Assert.assertEquals(property.value, driverProp.getDefaultValue()); + } + } + for (ClientConfigProperties clientProp : ClientConfigProperties.values()) { + if (clientProp.getKey().equalsIgnoreCase(property.name)) { + Assert.assertEquals(property.value, clientProp.getDefaultValue()); + } + } + } + } + + Assert.assertTrue(checkPropertiesCopy.isEmpty(), "Not checked properties: " + checkProperties); } catch (SQLException e) { Assert.fail("Failed to get property info", e); } } + @DataProvider(name = "testGetPropertyInfoDP") + public Object[][] testGetPropertyInfoDP() { + return new Object[][]{ + {"jdbc:ch://localhost:8123/?async=true", null, Map.of(ClientConfigProperties.ASYNC_OPERATIONS.getKey(), "true")}, + {"jdbc:ch://localhost:8123/?connection_ttl=10000&max_threads_per_client=100", null, Map.of(ClientConfigProperties.CONNECTION_TTL.getKey(), "10000", + ClientConfigProperties.MAX_THREADS_PER_CLIENT.getKey(), "100")}, + {"jdbc:ch://localhost:8123/?client_retry_on_failures=NoHttpResponse,SocketTimeout", null, Map.of(ClientConfigProperties.CLIENT_RETRY_ON_FAILURE.getKey(), "NoHttpResponse,SocketTimeout")}, + {"jdbc:ch://localhost:8123/?connection_ttl=10000&client_retry_on_failures=NoHttpResponse,SocketTimeout&max_threads_per_client=100", + null, Map.of(ClientConfigProperties.CLIENT_RETRY_ON_FAILURE.getKey(), "NoHttpResponse,SocketTimeout", + ClientConfigProperties.CONNECTION_TTL.getKey(), "10000", + ClientConfigProperties.MAX_THREADS_PER_CLIENT.getKey(), "100")} + }; + } + @Test(groups = {"integration"}) public void testGetDriverVersion() { Driver driver = new Driver(); From b9d8419db4f47c00f676ee19c9b8e276045f3f1c Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Fri, 19 Sep 2025 22:05:08 -0700 Subject: [PATCH 3/3] added more version tests --- jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java index fa8173b37..7e1fb77df 100644 --- a/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java +++ b/jdbc-v2/src/test/java/com/clickhouse/jdbc/DriverTest.java @@ -122,6 +122,7 @@ public static Object[][] testParsingDriverVersionDP() { {"1.2.1", 0x010002, 1}, {"5000.20.1", 0x13880014, 1}, {"2.1.1", 0x020001, 1}, + {"2.1.1.0", 0x020001, 1}, }; }