[jdbc-v2] JDBC fails to execute query if user is `readonly`
Description
The issue was reproduced while executing the query in DBeaver with a read-only user.
Error Log or Exception StackTrace
2025-06-10 11:55:23.220 - SQL Error [22000]: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
org.jkiss.dbeaver.model.sql.DBSQLException: SQL Error [22000]: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:130)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeStatement(SQLQueryJob.java:657)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.lambda$2(SQLQueryJob.java:550)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.executeSingleQuery(SQLQueryJob.java:569)
at org.jkiss.dbeaver.ui.editors.sql.execute.SQLQueryJob.extractData(SQLQueryJob.java:1043)
at org.jkiss.dbeaver.ui.editors.sql.SQLEditor$QueryResultsContainer.readData(SQLEditor.java:4363)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.lambda$0(ResultSetJobDataRead.java:128)
at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetJobDataRead.run(ResultSetJobDataRead.java:126)
at org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer$ResultSetDataPumpJob.run(ResultSetViewer.java:5145)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:119)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.sql.SQLException: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
at com.clickhouse.jdbc.internal.ExceptionUtils.toSqlState(ExceptionUtils.java:67)
at com.clickhouse.jdbc.internal.ExceptionUtils.toSqlState(ExceptionUtils.java:42)
at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:149)
at com.clickhouse.jdbc.StatementImpl.execute(StatementImpl.java:309)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.execute(JDBCStatementImpl.java:344)
at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl.executeStatement(JDBCStatementImpl.java:128)
... 12 more
Caused by: com.clickhouse.client.api.ServerException: Code: 164. DB::Exception: <Unreadable error message> (transport error: 500)
at com.clickhouse.client.api.internal.HttpAPIClientHelper.readError(HttpAPIClientHelper.java:371)
at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:426)
at com.clickhouse.client.api.Client.lambda$query$10(Client.java:1723)
at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2156)
at com.clickhouse.client.api.Client.query(Client.java:1766)
at com.clickhouse.client.api.Client.query(Client.java:1667)
at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:135)
... 15 more
Environment
- Client version: 0.8.6
- Language version: 17
We also need to add tests for read-only user. see examples: https://github.com/ClickHouse/clickhouse-js/blob/main/packages/client-common/tests/integration/read_only_user.test.ts
I'm not sure why you observe DB::Exception: <Unreadable error message> (transport error: 500) when nodejs client tests assert against an error message https://github.com/ClickHouse/clickhouse-js/blob/main/packages/client-common/tests/integration/read_only_user.test.ts#L66
If the driver doesn't work with the default settings for the read only user, for example, because the driver changes settings, we need to review the list of changed settings. Using readonly=1 user is a typical pattern in BI, when a UI tool provides only read access to a data store.
Seems relate to https://github.com/ClickHouse/clickhouse-java/issues/2510
Is there any progress on this? I stumbled upon this error running queries from readonly user with DBeaver, had to switch to DataGrip – it works.
Good day, @TechGeorgii !
Would you put more details - version of JDBC and DBeaver, how to reproduce? We currently thinking that the issue is fixed. It was caused that we were using server settings and error tells that settings cannot be changed by readonly user.
Thanks!
Good day, @TechGeorgii !
Would you put more details - version of JDBC and DBeaver, how to reproduce? We currently thinking that the issue is fixed. It was caused that we were using server settings and error tells that settings cannot be changed by readonly user.
Thanks!
After I updated JDBC driver to 0.9.4 the issued went away, so I guess old driver version caused this problem.
Thank you @TechGeorgii !