-
Notifications
You must be signed in to change notification settings - Fork 614
Description
It looks like parsing of JDBC URL does not support dash (hyphen) in database name. This results in Code: 81. DB::Exception: Database test does not exist. when trying to connect to database named test-dash.
Found in 0.8.4 but this part of code in master is the same.
RegEx at
clickhouse-java/jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java
Line 129 in b2692a3
| private static final Pattern URL_REGEXP = Pattern.compile("(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$"); |
>>> import re
>>> re.match('(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w]+))?\\/?\\??(.*)$', 'https://host-name:8123/test-dash?param=pampam').groups()
('https:', 'host-name', '8123', 'test', '-dash?param=pampam')
(Tested in python as it was a quick test but I assume \w is the same)
Note the 4th group only has test and -dash is already in 5th group where params should reside.
Adding - to characters set seems to fix parsing:
> re.match('(https?:)?\\/\\/([\\w\\.\\-]+|\\[[0-9a-fA-F:]+\\]):?([\\d]*)(?:\\/([\\w-]+))?\\/?\\??(.*)$', 'https://host-name:8123/test-dash?param=pampam').groups()
('https:', 'host-name', '8123', 'test-dash', 'param=pampam')
Here the 4th group contains full DB name test-dash
There was already a similar issue long ago: #251 but that was for client V1.