Skip to content

Commit 4e35b40

Browse files
committed
Restore IPv6 address support in the JDBC URL connection.
Prior to 1.8.0 it was working properly. As of 1.8.x, the `URL_REGEXP` rejected URLs like `jdbc:clickhouse://[::1]/`.
1 parent b5eb233 commit 4e35b40

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static String stripJDBCPrefix(String url) {
126126
* <li>5 - query parameters as is (optional)</li>
127127
* </ul>
128128
*/
129-
private static final Pattern URL_REGEXP = Pattern.compile("(https?:)?\\/\\/([\\w\\.\\-]+):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$");
129+
private static final Pattern URL_REGEXP = Pattern.compile("(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$");
130130

131131
/**
132132
* Extracts positions of parameters names.

jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/JdbcConfigurationTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public static Object[][] testConnectionUrlDataProvider() {
4040

4141
return new Object[][] {
4242
{"jdbc:clickhouse://localhost:8123/", "http://localhost:8123", defaultProps, defaultParams},
43+
{"jdbc:clickhouse://127.0.0.1:8123/", "http://127.0.0.1:8123", defaultProps, defaultParams},
44+
{"jdbc:clickhouse://[::1]:8123/", "http://[::1]:8123", defaultProps, defaultParams},
45+
{"jdbc:clickhouse://[::1]/", "http://[::1]", defaultProps, defaultParams},
4346
{"jdbc:clickhouse://localhost:8443/clickhouse?param1=value1&param2=value2", "http://localhost:8443", defaultProps, simpleParams},
4447
{"jdbc:clickhouse:https://localhost:8123/clickhouse?param1=value1&param2=value2", "https://localhost:8123", defaultProps, simpleParams},
4548
{"jdbc:clickhouse://localhost:8443/", "https://localhost:8443", useSSL, useSSLParams},

0 commit comments

Comments
 (0)