Closed ant0nk closed 2 years ago
Hi @ant0nk, the datasource config looks correct. Does this /etc/clickhouse-jdbc-bridge/config/drivers/db2jcc4.jar a valid jar file? Which version of jdbc bridge you're using?
Hi @zhicwu , it is correct jdbc-driver as I'm successfully using it with DBeaver, SQL Developer, Spark etc. The version I'm trying to use is 2.0.2 I guess, I downloaded it from https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.2/clickhouse-jdbc-bridge-2.0.2-shaded.jar
as mentioned in Java CLI-related example:
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.2/clickhouse-jdbc-bridge-2.0.2-shaded.jar
wget -P config/datasources https://raw.githubusercontent.com/ClickHouse/clickhouse-jdbc-bridge/master/misc/quick-start/jdbc-bridge/config/datasources/ch-server.json
java -jar clickhouse-jdbc-bridge-2.0.2-shaded.jar
At first I tried RPM-package as I'm using CentOS but unfortunately it doesn't see config files at all. I will compose one more issue about it.
Sorry for the inconvenience. Is there any specific reason of using 2.0.2? In general you should consider to use docker along with latest version like 2.1.0 or at least 2.0.7.
Anyway, I just tried 2.0.2 and it works for me(I don't have DB2 but the exception showed the driver worked well):
cd /root
mkdir -p config/datasources
vi config/datasources/db2.json
wget https://github.com/ClickHouse/clickhouse-jdbc-bridge/releases/download/v2.0.2/clickhouse-jdbc-bridge-2.0.2-shaded.jar
wget -P drivers https://repo1.maven.org/maven2/com/ibm/db2/jcc/11.5.7.0/jcc-11.5.7.0.jar
java -jar clickhouse-jdbc-bridge-2.0.2-shaded.jar
...
2022-04-29 15:32:05.005 [vert.x-worker-thread-2] [INFO ] {BaseRepository:206} - Adding NamedDataSource(id=test)...
2022-04-29 15:32:05.005 [vert.x-worker-thread-2] [WARN ] {DriverDataSource:70} - Registered driver with driverClassName=com.ibm.db2.jcc.DB2Driver was not found, trying direct instantiation.
2022-04-29 15:32:06.006 [vert.x-worker-thread-2] [ERROR] {HikariPool:593} - test - Exception during pool initialization.
com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][4.31.10] Exception java.net.ConnectException: Error opening socket to server localhost/127.0.0.1 on port 446 with message: Connection refused. ERRORCODE=-4499, SQLSTATE=08001
at com.ibm.db2.jcc.am.b7.a(b7.java:338)
...
config/datasources/db2.json
{
"test": {
"aliases": [
"self"
],
"driverUrls": [
"/root/drivers/jcc-11.5.7.0.jar"
],
"driverClassName": "com.ibm.db2.jcc.DB2Driver",
"jdbcUrl": "jdbc:db2://localhost:446/TEST",
"username": "aaa",
"password": "aaa",
"maximumPoolSize": 1
}
}
I've added db2 license file and previous error vanished (it's very strange, I tried it before, maybe without newline between paths):
{
"test": {
"aliases": [
"self"
],
"driverUrls": [
"/etc/clickhouse-jdbc-bridge/config/drivers/db2jcc4.jar",
"/etc/clickhouse-jdbc-bridge/config/drivers/db2jcc_license_cisuz.jar"
],
"driverClassName": "com.ibm.db2.jcc.DB2Driver",
"jdbcUrl": "jdbc:db2://*.*.*.*:446/TEST",
"username": "****",
"password": "****",
"maximumPoolSize": 1
}
}
But another one arised:
2022-04-29 10:37:02.002 [vert.x-eventloop-thread-0] [INFO ] {JdbcBridgeVerticle:276} - Server http://0.0.0.0:9019 started in 763 ms
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [INFO ] {JsonFileRepository:87} - Loading NamedDataSource configuration...
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [INFO ] {BaseRepository:206} - Adding NamedDataSource(id=test)...
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [WARN ] {DriverDataSource:70} - Registered driver with driverClassName=com.ibm.db2.jcc.DB2Driver was not found, trying direct instantiation.
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [ERROR] {PoolBase:465} - test - Failed to execute connection test query (DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;+ - AS <IDENTIFIER>, DRIVER=4.24.92).
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [ERROR] {HikariPool:497} - test - Error thrown while acquiring connection from data source
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;+ - AS <IDENTIFIER>, DRIVER=4.24.92
at com.ibm.db2.jcc.am.b6.a(b6.java:810)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:140)
at com.ibm.db2.jcc.am.k3.c(k3.java:2817)
at com.ibm.db2.jcc.am.k3.d(k3.java:2801)
at com.ibm.db2.jcc.am.k3.a(k3.java:2227)
at com.ibm.db2.jcc.t4.ab.i(ab.java:205)
at com.ibm.db2.jcc.t4.ab.b(ab.java:96)
at com.ibm.db2.jcc.t4.p.a(p.java:32)
at com.ibm.db2.jcc.t4.av.i(av.java:150)
at com.ibm.db2.jcc.am.k3.al(k3.java:2196)
at com.ibm.db2.jcc.am.k3.a(k3.java:3323)
at com.ibm.db2.jcc.am.k3.e(k3.java:1126)
at com.ibm.db2.jcc.am.k3.execute(k3.java:1105)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.executeSql(PoolBase.java:577)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkValidationSupport(PoolBase.java:461)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:441)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:410)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:363)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.<init>(JdbcDataSource.java:438)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.newInstance(JdbcDataSource.java:297)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ru.yandex.clickhouse.jdbcbridge.core.Extension.newInstance(Extension.java:224)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.createFromConfig(BaseRepository.java:97)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.update(BaseRepository.java:209)
at ru.yandex.clickhouse.jdbcbridge.impl.JsonFileRepository.reload(JsonFileRepository.java:94)
at ru.yandex.clickhouse.jdbcbridge.JdbcBridgeVerticle.lambda$null$5(JdbcBridgeVerticle.java:591)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at ru.yandex.clickhouse.jdbcbridge.internal.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [ERROR] {HikariPool:593} - test - Exception during pool initialization.
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;+ - AS <IDENTIFIER>, DRIVER=4.24.92
at com.ibm.db2.jcc.am.b6.a(b6.java:810)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:140)
at com.ibm.db2.jcc.am.k3.c(k3.java:2817)
at com.ibm.db2.jcc.am.k3.d(k3.java:2801)
at com.ibm.db2.jcc.am.k3.a(k3.java:2227)
at com.ibm.db2.jcc.t4.ab.i(ab.java:205)
at com.ibm.db2.jcc.t4.ab.b(ab.java:96)
at com.ibm.db2.jcc.t4.p.a(p.java:32)
at com.ibm.db2.jcc.t4.av.i(av.java:150)
at com.ibm.db2.jcc.am.k3.al(k3.java:2196)
at com.ibm.db2.jcc.am.k3.a(k3.java:3323)
at com.ibm.db2.jcc.am.k3.e(k3.java:1126)
at com.ibm.db2.jcc.am.k3.execute(k3.java:1105)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.executeSql(PoolBase.java:577)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkValidationSupport(PoolBase.java:461)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:441)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:410)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:363)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.<init>(JdbcDataSource.java:438)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.newInstance(JdbcDataSource.java:297)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ru.yandex.clickhouse.jdbcbridge.core.Extension.newInstance(Extension.java:224)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.createFromConfig(BaseRepository.java:97)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.update(BaseRepository.java:209)
at ru.yandex.clickhouse.jdbcbridge.impl.JsonFileRepository.reload(JsonFileRepository.java:94)
at ru.yandex.clickhouse.jdbcbridge.JdbcBridgeVerticle.lambda$null$5(JdbcBridgeVerticle.java:591)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at ru.yandex.clickhouse.jdbcbridge.internal.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
2022-04-29 10:37:02.002 [vert.x-worker-thread-2] [WARN ] {BaseRepository:222} - Failed to add NamedDataSource(id=test)
java.lang.IllegalStateException: Failed to create instance from extension: class ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource
at ru.yandex.clickhouse.jdbcbridge.core.Extension.newInstance(Extension.java:227)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.createFromConfig(BaseRepository.java:97)
at ru.yandex.clickhouse.jdbcbridge.core.BaseRepository.update(BaseRepository.java:209)
at ru.yandex.clickhouse.jdbcbridge.impl.JsonFileRepository.reload(JsonFileRepository.java:94)
at ru.yandex.clickhouse.jdbcbridge.JdbcBridgeVerticle.lambda$null$5(JdbcBridgeVerticle.java:591)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.ContextImpl.lambda$executeBlocking$2(ContextImpl.java:313)
at ru.yandex.clickhouse.jdbcbridge.internal.vertx.core.impl.TaskQueue.run(TaskQueue.java:76)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at ru.yandex.clickhouse.jdbcbridge.internal.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:750)
Caused by: ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;+ - AS <IDENTIFIER>, DRIVER=4.24.92
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:595)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:574)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.<init>(JdbcDataSource.java:438)
at ru.yandex.clickhouse.jdbcbridge.impl.JdbcDataSource.newInstance(JdbcDataSource.java:297)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ru.yandex.clickhouse.jdbcbridge.core.Extension.newInstance(Extension.java:224)
... 10 more
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=<END-OF-STATEMENT>;+ - AS <IDENTIFIER>, DRIVER=4.24.92
at com.ibm.db2.jcc.am.b6.a(b6.java:810)
at com.ibm.db2.jcc.am.b6.a(b6.java:66)
at com.ibm.db2.jcc.am.b6.a(b6.java:140)
at com.ibm.db2.jcc.am.k3.c(k3.java:2817)
at com.ibm.db2.jcc.am.k3.d(k3.java:2801)
at com.ibm.db2.jcc.am.k3.a(k3.java:2227)
at com.ibm.db2.jcc.t4.ab.i(ab.java:205)
at com.ibm.db2.jcc.t4.ab.b(ab.java:96)
at com.ibm.db2.jcc.t4.p.a(p.java:32)
at com.ibm.db2.jcc.t4.av.i(av.java:150)
at com.ibm.db2.jcc.am.k3.al(k3.java:2196)
at com.ibm.db2.jcc.am.k3.a(k3.java:3323)
at com.ibm.db2.jcc.am.k3.e(k3.java:1126)
at com.ibm.db2.jcc.am.k3.execute(k3.java:1105)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.executeSql(PoolBase.java:577)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkValidationSupport(PoolBase.java:461)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.checkDriverSupport(PoolBase.java:441)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.setupConnection(PoolBase.java:410)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:363)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:477)
at ru.yandex.clickhouse.jdbcbridge.internal.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:560)
... 19 more
I tried to specify connectionTestQuery but it didn't help.
The exception looks like related to the validation query. By default connectionTestQuery
is set to select 1
, which might not work on DB2?
Anyway, you said you tried the option but have you checked if the query worked on other JDBC client like DBeaver etc. using the exact same driver, connection URL and credentials?
Yes, same query works in DBeaver. Maybe there are some specific requirements for the query? Like number of returned rows, columns etc.
The validation query should be simple enough and in general returns zero or one row.
What was the error you got using updated validation query? Still com.ibm.db2.jcc.am.SqlSyntaxErrorException
?
Finally it works after I added:
"connectionTestQuery":"select 1 from dat.fc"
Closing the issue. Thank you very much.
I'm trying to connect to DB2-source and get error like this:
the source config is: