Skip to content

Commit 3c598ef

Browse files
committed
Updated version to latest and gave reference in JDBC to server settings configuration
1 parent f4cec15 commit 3c598ef

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

docs/integrations/language-clients/java/client/_snippets/_v0_8.mdx

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import Tabs from '@theme/Tabs';
22
import TabItem from '@theme/TabItem';
33
import WideTableWrapper from '@site/src/components/WideTableWrapper/WideTableWrapper';
4+
import TOCInline from '@theme/TOCInline';
5+
6+
7+
<TOCInline toc={toc} />
8+
49

510
Java client library to communicate with a DB server through its protocols. The current implementation only supports the [HTTP interface](/interfaces/http).
611
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
1419
<Tabs groupId="client-setup">
1520
<TabItem value="maven" label="Maven" >
1621

17-
```xml
22+
```xml
1823
<dependency>
1924
<groupId>com.clickhouse</groupId>
2025
<artifactId>client-v2</artifactId>
21-
<version>0.9.1</version>
26+
<version>0.9.3</version>
2227
</dependency>
2328
```
2429

@@ -27,14 +32,14 @@ The library provides its own API to send requests to a server. The library also
2732

2833
```kotlin
2934
// https://mvnrepository.com/artifact/com.clickhouse/client-v2
30-
implementation("com.clickhouse:client-v2:0.9.1")
35+
implementation("com.clickhouse:client-v2:0.9.3")
3136
```
3237
</TabItem>
3338
<TabItem value="gradle" label="Gradle">
3439

3540
```groovy
3641
// https://mvnrepository.com/artifact/com.clickhouse/client-v2
37-
implementation 'com.clickhouse:client-v2:0.9.1'
42+
implementation 'com.clickhouse:client-v2:0.9.3'
3843
```
3944

4045
</TabItem>
@@ -110,7 +115,7 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
110115
|-----------------------|-----------------------------|:--------------------------------------------|
111116
| `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` |
112117
| `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. |
114119
| `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` |
115120
| `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` |
116121
| `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.
130135
| `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`|
131136
| `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` |
132137
| `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 |
134139
| `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` |
135140
| `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`|
136141
| `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
372377
**Examples**
373378

374379
```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.
376381
client.register(ArticleViewEvent.class, client.getTableSchema(TABLE_NAME));
377382

378383
List<ArticleViewEvent> events = loadBatch();
379384

380385
try (InsertResponse response = client.insert(TABLE_NAME, events).get()) {
381-
// handle response, then it will be closed and connection that served request will be released.
386+
// handle response, then it will be closed and connection that served request will be released.
382387
}
383388
```
384389

@@ -419,7 +424,7 @@ Sends `sqlQuery` as is. Response format is set by query settings. `QueryResponse
419424

420425
**Signatures**
421426

422-
```java
427+
```java
423428
CompletableFuture<QueryResponse> query(String sqlQuery, QuerySettings settings)
424429
CompletableFuture<QueryResponse> query(String sqlQuery)
425430
```
@@ -436,7 +441,7 @@ Future of `QueryResponse` type - a result dataset and additional information lik
436441

437442
**Examples**
438443

439-
```java
444+
```java
440445
final String sql = "select * from " + TABLE_NAME + " where title <> '' limit 10";
441446

442447
// Default format is RowBinaryWithNamesAndTypesFormatReader so reader have all information about columns
@@ -453,21 +458,21 @@ try (QueryResponse response = client.query(sql).get(3, TimeUnit.SECONDS);) {
453458
String title = reader.getString("title");
454459
String url = reader.getString("url");
455460

456-
// collecting data
461+
// collecting data
457462
}
458463
} catch (Exception e) {
459464
log.error("Failed to read data", e);
460465
}
461466

462-
// put business logic outside of the reading block to release http connection asap.
467+
// put business logic outside of the reading block to release http connection asap.
463468
```
464469

465470
### query(String sqlQuery, Map&lt;String, Object> queryParams, QuerySettings settings) {#querystring-sqlquery-mapltstring-object-queryparams-querysettings-settings}
466471

467472
Sends `sqlQuery` as is. Additionally will send query parameters so the server can compile the SQL expression.
468473

469474
**Signatures**
470-
```java
475+
```java
471476
CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Object> queryParams, QuerySettings settings)
472477
```
473478

@@ -487,7 +492,7 @@ Future of `QueryResponse` type - a result dataset and additional information lik
487492

488493
```java showLineNumbers
489494

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.
491496
Map<String, Object> queryParams = new HashMap<>();
492497
queryParams.put("param1", 2);
493498

@@ -500,7 +505,7 @@ try (QueryResponse response =
500505
while (reader.hasNext()) {
501506
reader.next(); // Read the next record from stream and parse it
502507

503-
// reading data
508+
// reading data
504509
}
505510

506511
} catch (Exception e) {
@@ -514,7 +519,7 @@ try (QueryResponse response =
514519
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.
515520

516521
**Signatures**
517-
```java
522+
```java
518523
List<GenericRecord> queryAll(String sqlQuery)
519524
```
520525

@@ -594,7 +599,7 @@ Fetches table schema for the `table`.
594599

595600
**Signatures**
596601

597-
```java
602+
```java
598603
TableSchema getTableSchema(String table)
599604
TableSchema getTableSchema(String table, String database)
600605
```
@@ -615,7 +620,7 @@ Fetches schema from a SQL statement.
615620

616621
**Signatures**
617622

618-
```java
623+
```java
619624
TableSchema getTableSchemaFromQuery(String sql)
620625
```
621626

@@ -636,7 +641,7 @@ Column match is found by extracting its name from a method name. For example, `g
636641

637642
**Signatures**
638643

639-
```java
644+
```java
640645
void register(Class<?> clazz, TableSchema schema)
641646
```
642647

@@ -648,7 +653,7 @@ void register(Class<?> clazz, TableSchema schema)
648653

649654
**Examples**
650655

651-
```java showLineNumbers
656+
```java showLineNumbers
652657
client.register(ArticleViewEvent.class, client.getTableSchema(TABLE_NAME));
653658
```
654659

docs/integrations/language-clients/java/index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: 'Java'
3+
sidebar_position: 1
34
keywords: ['clickhouse', 'java', 'jdbc', 'client', 'integrate', 'r2dbc']
45
description: 'Options for connecting to ClickHouse from Java'
56
slug: /integrations/java
@@ -20,7 +21,7 @@ import CodeBlock from '@theme/CodeBlock';
2021

2122
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.
2223

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.
2425

2526
### Supported data types {#supported-data-types}
2627

@@ -83,7 +84,7 @@ Java Client was developed far back in 2015. Its codebase became very hard to mai
8384
- AggregatedFunction - :warning: does not support `SELECT * FROM table ...`
8485
- Decimal - `SET output_format_decimal_trailing_zeros=1` in 21.9+ for consistency
8586
- 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
8788
:::
8889

8990
### Features {#features}
@@ -94,7 +95,8 @@ Table of features of the clients:
9495
|----------------------------------------------|:---------:|:---------:|:---------:|
9596
| Http Connection ||| |
9697
| Http Compression (LZ4) ||| |
97-
| Server Response Compression - LZ4 ||| |
98+
| Application Controlled Compression ||| |
99+
| Server Response Compression - LZ4 ||| |
98100
| Client Request Compression - LZ4 ||| |
99101
| HTTPS ||| |
100102
| Client SSL Cert (mTLS) ||| |
@@ -109,6 +111,7 @@ Table of features of the clients:
109111
| Log Comment ||| |
110112
| Session Roles ||| |
111113
| SSL Client Authentication ||| |
114+
| SNI Configuration ||| |
112115
| Session timezone ||| |
113116

114117
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
122125

123126
### Logging {#logging}
124127

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`.
126129
For example, if you are using Maven you could add the following dependency to your `pom.xml` file:
127130

128131
```xml title="pom.xml"

docs/integrations/language-clients/java/jdbc/_snippets/_v0_8.mdx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Tabs from '@theme/Tabs';
22
import TabItem from '@theme/TabItem';
3+
import TOCInline from '@theme/TOCInline';
4+
5+
6+
<TOCInline toc={toc} />
37

48
:::note
59
`clickhouse-jdbc` implements the standard JDBC interface using the latest java client.
@@ -35,7 +39,7 @@ In 0.8 we tried to make the driver more strictly follow the JDBC specification,
3539
<dependency>
3640
<groupId>com.clickhouse</groupId>
3741
<artifactId>clickhouse-jdbc</artifactId>
38-
<version>0.9.1</version>
42+
<version>0.9.3</version>
3943
<classifier>shaded-all</classifier>
4044
</dependency>
4145
```
@@ -45,14 +49,14 @@ In 0.8 we tried to make the driver more strictly follow the JDBC specification,
4549

4650
```kotlin
4751
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc
48-
implementation("com.clickhouse:clickhouse-jdbc:0.9.1:shaded-all")
52+
implementation("com.clickhouse:clickhouse-jdbc:0.9.3:shaded-all")
4953
```
5054
</TabItem>
5155
<TabItem value="gradle" label="Gradle">
5256

5357
```groovy
5458
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc
55-
implementation 'com.clickhouse:clickhouse-jdbc:0.9.1:shaded-all'
59+
implementation 'com.clickhouse:clickhouse-jdbc:0.9.3:shaded-all'
5660
```
5761

5862
</TabItem>
@@ -67,9 +71,9 @@ In 0.8 we tried to make the driver more strictly follow the JDBC specification,
6771
- `jdbc:clickhouse:http://localhost:8123`
6872
- `jdbc:clickhouse:https://localhost:8443?ssl=true`
6973

70-
**Connection Properties**:
74+
### Connection Properties:
7175

72-
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).
7377
Where possible methods will return an `SQLFeatureNotSupportedException` if the feature is not supported. Other custom properties include:
7478

7579
| Property | Default | Description |
@@ -81,6 +85,10 @@ Where possible methods will return an `SQLFeatureNotSupportedException` if the f
8185
| `jdbc_resultset_auto_close` | `true` | Automatically closes `ResultSet` when `Statement` is closed |
8286
| `beta.row_binary_for_simple_insert` | `false` | Use `PreparedStatement` implementation based on `RowBinary` writer. Works only for `INSERT INTO ... VALUES` queries. |
8387

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+
8492
## Supported data types {#supported-data-types}
8593

8694
JDBC Driver supports the same data formats as the underlying [java client](/integrations/language-clients/java/client/client.mdx).

0 commit comments

Comments
 (0)