metabase-clickhouse-driver icon indicating copy to clipboard operation
metabase-clickhouse-driver copied to clipboard

Support urls with underscores

Open Dock1100 opened this issue 6 years ago • 1 comments

On the Metabase db configuration page, if the host contains underscores, e.g.: clickhouse_app, connection attempt always results in port is missed or wrong. With hosts without underscores, it works like a correctly.

Metabase log:

08-09 07:59:08 DEBUG middleware.log :: PUT /api/database/4 400 10 ms (1 DB calls) 
{:valid false, :dbname "port is missed or wrong", :message "port is missed or wrong"}

Driver version: 0.3 https://github.com/enqueue/metabase-clickhouse-driver/releases/download/0.3/clickhouse.metabase-driver.jar Metabase version: v0.32.10

Dock1100 avatar Aug 09 '19 08:08 Dock1100

How to solve this problem ?

iusik avatar Apr 21 '22 18:04 iusik

the problem seem to come from a bug/strictness in java.net.URI from jdk ...

java.net.URI are used in https://github.com/ClickHouse/clickhouse-jdbc/blob/master/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/ClickhouseJdbcUrlParser.java#L42 to decode jdbc url...

two bug are in jdk : https://bugs.openjdk.org/browse/JDK-8221675 and https://bugs.openjdk.org/browse/JDK-8019345 and https://stackoverflow.com/questions/22203111/is-javas-uri-resolve-incompatible-with-rfc-3986-when-the-relative-uri-contains.

in fact java.net.URI are based on old dns name RFC2396 ... that had been updated after in RFC3986....

also spring had the same pb... https://github.com/spring-projects/spring-framework/issues/24439

the good solution while be to fix in java.net.URI... maybe in jdk18+... https://bugs.openjdk.org/browse/JDK-8291591 and https://cr.openjdk.java.net/~dfuchs/writeups/updating-uri/

the other solution are to use alternative URI parse in clickhouse jdbc driver like in spring... with org.springframework.web.util.UriComponentsBuilder...

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/UriComponentsBuilder.html

i've opened an issue on clickhouse-jdbc about that : https://github.com/ClickHouse/clickhouse-jdbc/issues/1107

mcarbonneaux avatar Oct 12 '22 18:10 mcarbonneaux

i'found the message "port is missed or wrong" are throw by old clickhouse-jdbc 0.3.1 version.... an update of the clickhouse-jdbc dependancy to 0.3.2-patch11 can change a little the problem (the git a some change around that problem)...

and use com.clickhouse/clickhouse-jdbc in place of ru.yandex.clickhouse/clickhouse-jdbc :

<dependency>
    <!-- please stop using ru.yandex.clickhouse as it's been deprecated -->
    <groupId>com.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.3.2-patch11</version>
    <!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
    <classifier>all</classifier>
    <exclusions>
        <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
        </exclusion>
    </exclusions>
</dependency>

mcarbonneaux avatar Oct 12 '22 19:10 mcarbonneaux

Should be fixed in the upcoming 0.9.0 release as it will include JDBC driver 0.3.2-patch11 by default.

slvrtrn avatar Dec 02 '22 07:12 slvrtrn

Should be fixed in 0.9.0

slvrtrn avatar Dec 07 '22 11:12 slvrtrn