I am new using clickhouse and I have assembled a project in java using java client.
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-http-client</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.2.1</version>
</dependency>
HashMap<String, String> options = new HashMap<>();
options.put("user", "user");
options.put("password", "pass");
String url = "my-clickhouse-host";
ClickHouseNode server = ClickHouseNode.of(url, options);
ClickHouseRequest<?> read = ClickHouseClient.builder()
.nodeSelector(ClickHouseNodeSelector.of(ClickHouseProtocol.HTTP))
.option(ClickHouseClientOption.SOCKET_KEEPALIVE, true)
.build()
.read(server).write();
for (int i = 0; i < 11; i++) {
String id = UUID.randomUUID().toString();
String field1 = "field1" + (i);
String field2 = "field2" + (i);
String field3 = "field3" + (i);
String field4 = "field4" + (i);
String query = String.format("INSERT INTO mytable VALUES ('%s', '%s', '%s', '%s', '%s')",
id,
field1,
field2,
field3,
field4);
read.format(ClickHouseFormat.CustomSeparated)
.query(query)
.executeAndWait();
}
This code only inserts 10 records, after that I get an Code: 159. Execution timed out Exception
I have already tried to change and add some ClickHouseClientOptions but I always get the same behaviour. How can I reuse the same client connections in clickhouse using java client?
I am new using clickhouse and I have assembled a project in java using java client.
This code only inserts 10 records, after that I get an Code: 159. Execution timed out Exception
I have already tried to change and add some ClickHouseClientOptions but I always get the same behaviour. How can I reuse the same client connections in clickhouse using java client?