Skip to content

Commit f1648ae

Browse files
committed
Rework ClientVersioning component to use snippets
1 parent 2ab5265 commit f1648ae

File tree

9 files changed

+255
-258
lines changed

9 files changed

+255
-258
lines changed

docs/integrations/language-clients/java/client-v1.md renamed to docs/integrations/language-clients/java/client/_v0_7.mdx

-22
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
1-
---
2-
title: 'Client (0.7.x and earlier)'
3-
description: 'Java client library to communicate with a DB server through its protocols.'
4-
slug: /integrations/language-clients/java/client-v1
5-
displayed_sidebar: 'integrations'
6-
---
7-
81
import Tabs from '@theme/Tabs';
92
import TabItem from '@theme/TabItem';
10-
import CodeBlock from '@theme/CodeBlock';
11-
import ClientVersionDropdown from '@theme/ClientVersionDropdown/ClientVersionDropdown';
12-
13-
# Java client (0.7.x and earlier)
14-
15-
<ClientVersionDropdown versions={[
16-
{
17-
'version': 'v0.7.x',
18-
'slug': '/integrations/language-clients/java/client-v1'
19-
},
20-
{
21-
'version': 'v0.8+',
22-
'slug': '/docs/integrations/language-clients/java/client'
23-
}
24-
]}/>
253

264
Java client library to communicate with a DB server through its protocols. Current implementation supports only [HTTP interface](/interfaces/http). The library provides own API to send requests to a server.
275

docs/integrations/language-clients/java/client.md renamed to docs/integrations/language-clients/java/client/_v0_8.mdx

+24-48
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,14 @@
1-
---
2-
sidebar_label: 'Client 0.8+'
3-
sidebar_position: 2
4-
keywords: ['clickhouse', 'java', 'client', 'integrate']
5-
description: 'Java ClickHouse Connector 0.8+'
6-
slug: /integrations/language-clients/java/client
7-
title: 'Java Client (0.8+)'
8-
---
9-
101
import Tabs from '@theme/Tabs';
112
import TabItem from '@theme/TabItem';
12-
import CodeBlock from '@theme/CodeBlock';
13-
import ClientVersionDropdown from '@theme/ClientVersionDropdown/ClientVersionDropdown';
14-
15-
# Java client (0.8+)
16-
17-
<ClientVersionDropdown versions={[
18-
{
19-
'version': 'v0.8+',
20-
'slug': '/docs/integrations/language-clients/java/client'
21-
},
22-
{
23-
'version': 'v0.7.x',
24-
'slug': '/integrations/language-clients/java/client-v1'
25-
}
26-
]}/>
273

28-
Java client library to communicate with a DB server through its protocols. The current implementation only supports the [HTTP interface](/interfaces/http).
4+
Java client library to communicate with a DB server through its protocols. The current implementation only supports the [HTTP interface](/interfaces/http).
295
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*).
306

317
## Setup {#setup}
328

339
- Maven Central (project web page): https://mvnrepository.com/artifact/com.clickhouse/client-v2
3410
- Nightly builds (repository link): https://s01.oss.sonatype.org/content/repositories/snapshots/com/clickhouse/
35-
11+
<br/>
3612
<Tabs groupId="client-setup">
3713
<TabItem value="maven" label="Maven" >
3814

@@ -65,9 +41,9 @@ implementation 'com.clickhouse:client-v2:0.8.2'
6541
## Initialization {#initialization}
6642

6743
The Client object is initialized by `com.clickhouse.client.api.Client.Builder#build()`. Each client has its own context and no objects are shared between them.
68-
The Builder has configuration methods for convenient setup.
44+
The Builder has configuration methods for convenient setup.
6945

70-
Example:
46+
Example:
7147
```java showLineNumbers
7248
Client client = new Client.Builder()
7349
.addEndpoint("https://clickhouse-cloud-instance:8443/")
@@ -80,9 +56,9 @@ Example:
8056

8157
### Authentication {#authentication}
8258

83-
Authentication is configured per client at the initialization phase. There are three authentication methods supported: by password, by access token, by SSL Client Certificate.
59+
Authentication is configured per client at the initialization phase. There are three authentication methods supported: by password, by access token, by SSL Client Certificate.
8460

85-
Authentication by a password requires setting user name password by calling `setUsername(String)` and `setPassword(String)`:
61+
Authentication by a password requires setting user name password by calling `setUsername(String)` and `setPassword(String)`:
8662
```java showLineNumbers
8763
Client client = new Client.Builder()
8864
.addEndpoint("https://clickhouse-cloud-instance:8443/")
@@ -99,7 +75,7 @@ Authentication by an access token requires setting access token by calling `setA
9975
.build();
10076
```
10177

102-
Authentication by a SSL Client Certificate require setting username, enabling SSL Authentication, setting a client sertificate and a client key by calling `setUsername(String)`, `useSSLAuthentication(boolean)`, `setClientCertificate(String)` and `setClientKey(String)` accordingly:
78+
Authentication by a SSL Client Certificate require setting username, enabling SSL Authentication, setting a client sertificate and a client key by calling `setUsername(String)`, `useSSLAuthentication(boolean)`, `setClientCertificate(String)` and `setClientKey(String)` accordingly:
10379
```java showLineNumbers
10480
Client client = new Client.Builder()
10581
.useSSLAuthentication(true)
@@ -111,18 +87,18 @@ Client client = new Client.Builder()
11187
:::note
11288
SSL Authentication may be hard to troubleshoot on production because many errors from SSL libraries provide not enough information. For example, if client certificate and key do not match then server will terminate connection immediately (in case of HTTP it will be connection initiation stage where no HTTP requests are send so no response is sent).
11389

114-
Please use tools like [openssl](https://docs.openssl.org/master/man1/openssl/) to verify certificates and keys:
90+
Please use tools like [openssl](https://docs.openssl.org/master/man1/openssl/) to verify certificates and keys:
11591
- check key integrity: `openssl rsa -in [key-file.key] -check -noout`
11692
- check client certificate has matching CN for a user:
11793
- get CN from an user certificate - `openssl x509 -noout -subject -in [user.cert]`
118-
- verify same value is set in database `select name, auth_type, auth_params from system.users where auth_type = 'ssl_certificate'` (query will output `auth_params` with something like ` {"common_names":["some_user"]}`)
94+
- verify same value is set in database `select name, auth_type, auth_params from system.users where auth_type = 'ssl_certificate'` (query will output `auth_params` with something like ` {"common_names":["some_user"]}`)
11995

12096
:::
12197

12298

12399
## Configuration {#configuration}
124100

125-
All settings are defined by instance methods (a.k.a configuration methods) that make the scope and context of each value clear.
101+
All settings are defined by instance methods (a.k.a configuration methods) that make the scope and context of each value clear.
126102
Major configuration parameters are defined in one scope (client or operation) and do not override each other.
127103

128104
Configuration is defined during client creation. See `com.clickhouse.client.api.Client.Builder`.
@@ -189,9 +165,9 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
189165

190166
### ClickHouseFormat {#clickhouseformat}
191167

192-
Enum of [supported formats](/interfaces/formats). It includes all formats that ClickHouse supports.
168+
Enum of [supported formats](/interfaces/formats). It includes all formats that ClickHouse supports.
193169

194-
* `raw` - user should transcode raw data
170+
* `raw` - user should transcode raw data
195171
* `full` - the client can transcode data by itself and accepts a raw data stream
196172
* `-` - operation not supported by ClickHouse for this format
197173

@@ -337,7 +313,7 @@ client.insert(String tableName, List<?> data)
337313

338314
**Parameters**
339315

340-
`tableName` - name of the target table.
316+
`tableName` - name of the target table.
341317

342318
`data` - collection DTO (Data Transfer Object) objects.
343319

@@ -379,7 +355,7 @@ Configuration options for insert operations.
379355

380356
### InsertResponse {#insertresponse}
381357

382-
Response object that holds result of insert operation. It is only available if the client got response from a server.
358+
Response object that holds result of insert operation. It is only available if the client got response from a server.
383359

384360
:::note
385361
This object should be closed as soon as possible to release a connection because the connection cannot be re-used until all data of previous response is fully read.
@@ -405,13 +381,13 @@ CompletableFuture<QueryResponse> query(String sqlQuery)
405381

406382
**Parameters**
407383

408-
`sqlQuery` - a single SQL statement. The Query is sent as is to a server.
384+
`sqlQuery` - a single SQL statement. The Query is sent as is to a server.
409385

410386
`settings` - request settings.
411387

412388
**Return value**
413389

414-
Future of `QueryResponse` type - a result dataset and additional information like server side metrics. The Response object should be closed after consuming the dataset.
390+
Future of `QueryResponse` type - a result dataset and additional information like server side metrics. The Response object should be closed after consuming the dataset.
415391

416392
**Examples**
417393

@@ -452,15 +428,15 @@ CompletableFuture<QueryResponse> query(String sqlQuery, Map<String, Object> quer
452428

453429
**Parameters**
454430

455-
`sqlQuery` - sql expression with placeholders `{}`.
431+
`sqlQuery` - sql expression with placeholders `{}`.
456432

457433
`queryParams` - map of variables to complete the sql expression on server.
458434

459-
`settings` - request settings.
435+
`settings` - request settings.
460436

461437
**Return value**
462438

463-
Future of `QueryResponse` type - a result dataset and additional information like server side metrics. The Response object should be closed after consuming the dataset.
439+
Future of `QueryResponse` type - a result dataset and additional information like server side metrics. The Response object should be closed after consuming the dataset.
464440

465441
**Examples**
466442

@@ -503,7 +479,7 @@ List<GenericRecord> queryAll(String sqlQuery)
503479

504480
**Return value**
505481

506-
Complete dataset represented by a list of `GenericRecord` objects that provide access in row style for the result data.
482+
Complete dataset represented by a list of `GenericRecord` objects that provide access in row style for the result data.
507483

508484
**Examples**
509485

@@ -546,7 +522,7 @@ Configuration options for query operations.
546522

547523
### QueryResponse {#queryresponse}
548524

549-
Response object that holds result of query execution. It is only available if the client got a response from a server.
525+
Response object that holds result of query execution. It is only available if the client got a response from a server.
550526

551527
:::note
552528
This object should be closed as soon as possible to release a connection because the connection cannot be re-used until all data of previous response is fully read.
@@ -590,7 +566,7 @@ Returns a `TableSchema` object with list of table columns.
590566

591567
### getTableSchemaFromQuery(String sql) {#gettableschemafromquerystring-sql}
592568

593-
Fetches schema from a SQL statement.
569+
Fetches schema from a SQL statement.
594570

595571
**Signatures**
596572

@@ -610,8 +586,8 @@ Returns a `TableSchema` object with columns matching the `sql` expression.
610586

611587
### register(Class&lt;?> clazz, TableSchema schema) {#registerclasslt-clazz-tableschema-schema}
612588

613-
Compiles serialization and deserialization layer for the Java Class to use for writing/reading data with `schema`. The method will create a serializer and deserializer for the pair getter/setter and corresponding column.
614-
Column match is found by extracting its name from a method name. For example, `getFirstName` will be for the column `first_name` or `firstname`.
589+
Compiles serialization and deserialization layer for the Java Class to use for writing/reading data with `schema`. The method will create a serializer and deserializer for the pair getter/setter and corresponding column.
590+
Column match is found by extracting its name from a method name. For example, `getFirstName` will be for the column `first_name` or `firstname`.
615591

616592
**Signatures**
617593

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
sidebar_label: 'Client'
3+
sidebar_position: 2
4+
keywords: ['clickhouse', 'java', 'client', 'integrate']
5+
description: 'Java ClickHouse Connector'
6+
slug: /integrations/language-clients/java/client
7+
title: 'Java Client'
8+
---
9+
10+
import ClientVersionDropdown from '@theme/ClientVersionDropdown/ClientVersionDropdown';
11+
import v07 from './_v0_7.mdx'
12+
import v08 from './_v0_8.mdx'
13+
14+
<ClientVersionDropdown versions={[
15+
{
16+
'version': 'v0.8+',
17+
'snippet': v08
18+
},
19+
{
20+
'version': 'v0.7.x',
21+
'snippet': v07
22+
}
23+
]}/>

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import CodeBlock from '@theme/CodeBlock';
1111

1212
# Java Clients Overview
1313

14-
- [Client 0.8+](./client.md)
15-
- [JDBC 0.8+](./jdbc)
14+
- [Client 0.8+](./client/client.mdx)
15+
- [JDBC 0.8+](./jdbc/jdbc.mdx)
1616
- [R2DBC Driver](./r2dbc.md)
1717

1818
## ClickHouse Client {#clickhouse-client}

0 commit comments

Comments
 (0)