You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java client library to communicate with a DB server through its protocols. The current implementation only supports the [HTTP interface](/interfaces/http).
6
11
The library provides its own API to send requests to a server. The library also provides tools to work with different binary data formats (RowBinary* & Native*).
@@ -14,11 +19,11 @@ The library provides its own API to send requests to a server. The library also
14
19
<TabsgroupId="client-setup">
15
20
<TabItemvalue="maven"label="Maven" >
16
21
17
-
```xml
22
+
```xml
18
23
<dependency>
19
24
<groupId>com.clickhouse</groupId>
20
25
<artifactId>client-v2</artifactId>
21
-
<version>0.9.1</version>
26
+
<version>0.9.3</version>
22
27
</dependency>
23
28
```
24
29
@@ -27,14 +32,14 @@ The library provides its own API to send requests to a server. The library also
|`addEndpoint(String endpoint)`| - `endpoint` - URL formatted a server address. | Adds a server endpoint to list of available servers. Currently only one endpoint is supported. <br/> <br/> Default: `none` <br/> Enum: `none` <br/> Key: `none`|
112
117
|`addEndpoint(Protocol protocol, String host, int port, boolean secure)`| - `protocol` - connection protocol `com.clickhouse.client.api.enums.Protocol#HTTP`.<br />- `host` - IP or hostname of a server.<br />- `secure` - if communication should use secure version of the protocol (HTTPS) | Adds a server endpoint to list of available servers. Currently only one endpoint is supported. <br/> <br/> Default: `none` <br/> Enum: `none` <br/> Key: `none`|
113
-
|`setOption(String key, String value)`| - `key` - String key of the client configuration option.<br /> - `value` - String value of the option | Sets raw value of client options. Useful when reading configuration from properties files. |
118
+
|`setOption(String key, String value)`| - `key` - String key of the client configuration option.<br /> - `value` - String value of the option | Sets raw value of client options. Useful when reading configuration from properties files. |
114
119
|`setUsername(String username)`| - `username` - User's username to use while authentication | Sets username for an authentication method that is selected by further configuration <br/> <br/> Default: `default` <br/> Enum: `ClientConfigProperties.USER` <br/> Key: `user`|
115
120
|`setPassword(String password)`| - `password` - secret value for password authentication | Sets a secret for password authentication and effectively selects as authentication method <br/> <br/> Default: - <br/> Enum: `ClientConfigProperties.PASSWORD` <br/> Key: `password`|
116
121
|`setAccessToken(String accessToken)`| - `accessToken` - String representation of an access token | Sets an access token to authenticate with a sets corresponding authentication method <br/> <br/> Default: - <br/> Enum: `ClientConfigProperties.ACCESS_TOKEN` <br/> Key: `access_token`|
@@ -130,7 +135,7 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
130
135
|`setSocketLinger(int secondsToWait)`| - `secondsToWait` - number of seconds. | Set linger time for every TCP socket created by the client. <br/> <br/> Default: - <br/> Enum: `ClientConfigProperties.SOCKET_LINGER_OPT` <br/> Key: `socket_linger`|
131
136
|`compressServerResponse(boolean enabled)`| - `enabled` - flag that indicates if the option should be enabled | Sets if server should compress its responses. <br/> <br/> Default: `true` <br/> Enum: `ClientConfigProperties.COMPRESS_SERVER_RESPONSE` <br/> Key: `compress`|
132
137
|`compressClientRequest(boolean enabled)`| - `enabled` - flag that indicates if the option should be enabled | Sets if client should compress its requests. <br/> <br/> Default: `false` <br/> Enum: `ClientConfigProperties.COMPRESS_CLIENT_REQUEST` <br/> Key: `decompress`|
133
-
|`useHttpCompression(boolean enabled)`| - `enabled` - flag that indicates if the option should be enabled | Sets if HTTP compression should be used for client/server communications if corresponding options are enabled |
138
+
|`useHttpCompression(boolean enabled)`| - `enabled` - flag that indicates if the option should be enabled | Sets if HTTP compression should be used for client/server communications if corresponding options are enabled |
134
139
|`appCompressedData(boolean enabled)`| - `enabled` - flag that indicates if the option should be enabled | Tell client that compression will be handled by application. <br/> <br/> Default: `false` <br/> Enum: `ClientConfigProperties.APP_COMPRESSED_DATA` <br/> Key: `app_compressed_data`|
135
140
|`setLZ4UncompressedBufferSize(int size)`| - `size` - size in bytes | Sets size of a buffer that will receive uncompressed portion of a data stream. If buffer is underestimated - a new one will be created and corresponding warning will be present in logs. <br/> <br/> Default: `65536` <br/> Enum: `ClientConfigProperties.COMPRESSION_LZ4_UNCOMPRESSED_BUF_SIZE` <br/> Key: `compression.lz4.uncompressed_buffer_size`|
136
141
|`disableNativeCompression`| - `disable` - flag that indicates if the option should be disabled | Disable native compression. If set to true then native compression will be disabled. <br/> <br/> Default: `false` <br/> Enum: `ClientConfigProperties.DISABLE_NATIVE_COMPRESSION` <br/> Key: `disable_native_compression`|
@@ -372,13 +377,13 @@ Future of `InsertResponse` type - the result of the operation and additional inf
372
377
**Examples**
373
378
374
379
```java showLineNumbers
375
-
// Important step (done once) - register class to pre-compile object serializer according to the table schema.
380
+
// Important step (done once) - register class to pre-compile object serializer according to the table schema.
@@ -487,7 +492,7 @@ Future of `QueryResponse` type - a result dataset and additional information lik
487
492
488
493
```java showLineNumbers
489
494
490
-
// define parameters. They will be sent to the server along with the request.
495
+
// define parameters. They will be sent to the server along with the request.
491
496
Map<String, Object> queryParams =newHashMap<>();
492
497
queryParams.put("param1", 2);
493
498
@@ -500,7 +505,7 @@ try (QueryResponse response =
500
505
while (reader.hasNext()) {
501
506
reader.next(); // Read the next record from stream and parse it
502
507
503
-
// reading data
508
+
// reading data
504
509
}
505
510
506
511
} catch (Exception e) {
@@ -514,7 +519,7 @@ try (QueryResponse response =
514
519
Queries a data in `RowBinaryWithNamesAndTypes` format. Returns the result as a collection. Read performance is the same as with the reader but more memory is required to hold the whole dataset.
515
520
516
521
**Signatures**
517
-
```java
522
+
```java
518
523
List<GenericRecord> queryAll(String sqlQuery)
519
524
```
520
525
@@ -594,7 +599,7 @@ Fetches table schema for the `table`.
description: 'Options for connecting to ClickHouse from Java'
5
6
slug: /integrations/java
@@ -20,7 +21,7 @@ import CodeBlock from '@theme/CodeBlock';
20
21
21
22
Java client is a library implementing own API that abstracts details of network communications with ClickHouse server. Currently HTTP Interface is supported only. The library provide utilities to work with different ClickHouse formats and other related functions.
22
23
23
-
Java Client was developed far back in 2015. Its codebase became very hard to maintain, API is confusing, it is hard to optimize it further. So we have refactored it in 2024 into a new component `client-v2`. It has clear API, lighter codebase and more performance improvements, better ClickHouse formats support (RowBinary & Native mainly). JDBC will use this client in near feature.
24
+
Java Client was developed far back in 2015. Its codebase became very hard to maintain, API is confusing, it is hard to optimize it further. So we have refactored it in 2024 into a new component `client-v2`. It has clear API, lighter codebase and more performance improvements, better ClickHouse formats support (RowBinary & Native mainly). JDBC will use this client in near feature.
24
25
25
26
### Supported data types {#supported-data-types}
26
27
@@ -83,7 +84,7 @@ Java Client was developed far back in 2015. Its codebase became very hard to mai
83
84
- AggregatedFunction - :warning: does not support `SELECT * FROM table ...`
84
85
- Decimal - `SET output_format_decimal_trailing_zeros=1` in 21.9+ for consistency
85
86
- Enum - can be treated as both string and integer
86
-
- UInt64 - mapped to `long` in client-v1
87
+
- UInt64 - mapped to `long` in client-v1
87
88
:::
88
89
89
90
### Features {#features}
@@ -94,7 +95,8 @@ Table of features of the clients:
@@ -109,6 +111,7 @@ Table of features of the clients:
109
111
| Log Comment |✔ |✔ ||
110
112
| Session Roles |✔ |✔ ||
111
113
| SSL Client Authentication |✔ |✔ ||
114
+
| SNI Configuration |✔ |✗ ||
112
115
| Session timezone |✔ |✔ ||
113
116
114
117
JDBC Drive inherits same features as underlying client implementation. Other JDBC features are listed on its [page](/integrations/language-clients/java/jdbc).
@@ -122,7 +125,7 @@ JDBC Drive inherits same features as underlying client implementation. Other JDB
122
125
123
126
### Logging {#logging}
124
127
125
-
Our Java language client uses [SLF4J](https://www.slf4j.org/) for logging. You can use any SLF4J-compatible logging framework, such as `Logback` or `Log4j`.
128
+
Our Java language client uses [SLF4J](https://www.slf4j.org/) for logging. You can use any SLF4J-compatible logging framework, such as `Logback` or `Log4j`.
126
129
For example, if you are using Maven you could add the following dependency to your `pom.xml` file:
Beyond standard JDBC properties, the driver supports the ClickHouse-specific properties offered by the underlying [java client](/integrations/language-clients/java/client/client.mdx).
76
+
Beyond standard JDBC properties, the driver supports the ClickHouse-specific properties offered by the underlying [java client](/integrations/language-clients/java/client#client-configuration).
73
77
Where possible methods will return an `SQLFeatureNotSupportedException` if the feature is not supported. Other custom properties include:
74
78
75
79
| Property | Default | Description |
@@ -81,6 +85,10 @@ Where possible methods will return an `SQLFeatureNotSupportedException` if the f
81
85
|`jdbc_resultset_auto_close`|`true`| Automatically closes `ResultSet` when `Statement` is closed |
82
86
|`beta.row_binary_for_simple_insert`|`false`| Use `PreparedStatement` implementation based on `RowBinary` writer. Works only for `INSERT INTO ... VALUES` queries. |
83
87
88
+
#### Server Settings
89
+
90
+
All server settings should be prefixed with `clickhouse_setting_` (same as for the client [configuration](/integrations/language-clients/java/client#server-settings)).
91
+
84
92
## Supported data types {#supported-data-types}
85
93
86
94
JDBC Driver supports the same data formats as the underlying [java client](/integrations/language-clients/java/client/client.mdx).
0 commit comments