Search code examples
dockerjdbcclickhouse

Clickhouse does not find namedDataSource


On a Clickhouse Docker server, I try to use the Clickhouse-jdbc-bridge to access data on a Mariadb Docker server. But I am met with "NamedDataSource [jmdb-1] does not exist!" error.

I followed basic jdbc-bridge instructions over at https://clickhouse.com/docs/en/integrations/jdbc/jdbc-with-clickhouse

The jdbc-bridge is running:

root@c3410b41cd87:/# ps -aux | grep jdbc
root         251  0.3  1.3 6349608 108076 ?      Sl   13:28   0:17 java -jar /clickhouse-jdbc-bridge/clickhouse-jdbc-bridge-2.0.7-shaded.jar
root         529  0.0  0.0   6300   716 pts/0    S+   14:59   0:00 grep --color=auto jdbc

Here is my datasource file:

root@c3410b41cd87:/clickhouse-jdbc-bridge/config/datasources# cat jmdb-1.json 
{
  "jmdb-1": {
  "driverUrls": [
    "https://dlm.mariadb.com/2325871/Connectors/java/connector-java-3.0.5/mariadb-java-client-3.0.5.jar"
  ],
  "jdbcUrl": "jdbc:mariadb://10.5.1.11:13306",
  "username": "mariadb",
  "password": "maria1234"
  }
}

Here is my failing query with the resulting error:

SELECT * FROM jdbc('jmdb-1', 'mdb', 'mdb_sf1_region');

Received exception from server (version 22.5.1):
Code: 86. DB::Exception: Received from 10.5.1.31:9000. DB::Exception: Received error from remote server /columns_info?connection_string=jmdb-1&schema=mdb&table=mdb_sf1_region&external_table_functions_use_nulls=true. HTTP status code: 500 Internal Server Error, body: NamedDataSource [jmdb-1] does not exist!. 

I assume, that Clickhouse can reach the jdbc-bridge because of the rror. But i have no clue, why the bridge does not find the datasource file. Any help appreciated!


Solution

  • The error message from the Clickhouse server trying to use the Clickhouse-JDBC-bridge is misleading. At startup, the Clickhouse-JDBC-bridge loads the datasources and tries to connect with them. Only successful connected datasources get registered! So the Clickhouse-JDBC-bridge indeed finds the datasource file, but because there is an error in the file or the connection not working, the datasource does not get loaded and the error returned to the Clickhouse server says, the datasource does not exist.

    One can query all registered datasources via:

    SELECT * FROM jdbc('','show datasources');
    

    If one does not find his datasource there, it is likely, that there is a typo in the datasources file or the server the datasource points to is not up.

    On startup of the Clickhouse-JDBC-bridge, one can read the console output for further error messages about the datasource.