Async Java client for ClickHouse. clickhouse-client is an abstract module, so it does not work by itself until being used together with an implementation like clickhouse-http-client, clickhouse-grpc-client or clickhouse-cli-client.
See the ClickHouse website for the full documentation entry.
You can pass any client option(common, http, grpc, and cli) to ClickHouseRequest.option() and server setting to ClickHouseRequest.set() before execution, for instance:
client.connect("http://localhost/system")
.query("select 1")
// short version of option(ClickHouseClientOption.FORMAT, ClickHouseFormat.RowBinaryWithNamesAndTypes)
.format(ClickHouseFormat.RowBinaryWithNamesAndTypes)
.option(ClickHouseClientOption.SOCKET_TIMEOUT, 30000 * 2) // 60 seconds
.set("max_rows_to_read", 100)
.set("read_overflow_mode", "throw")
.execute()
.whenComplete((response, throwable) -> {
if (throwable != null) {
log.error("Unexpected error", throwable);
} else {
try {
for (ClickHouseRecord rec : response.records()) {
// ...
}
} finally {
response.close();
}
}
});Default value can be either configured via system property or environment variable.
For more example please check here.