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. Current implementation supports only [HTTP interface](/interfaces/http). The library provides own API to send requests to a server.
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).
29
5
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*).
30
6
31
7
## Setup {#setup}
32
8
33
9
- Maven Central (project web page): https://mvnrepository.com/artifact/com.clickhouse/client-v2
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.
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.
84
60
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)`:
@@ -99,7 +75,7 @@ Authentication by an access token requires setting access token by calling `setA
99
75
.build();
100
76
```
101
77
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:
103
79
```java showLineNumbers
104
80
Client client =newClient.Builder()
105
81
.useSSLAuthentication(true)
@@ -111,18 +87,18 @@ Client client = new Client.Builder()
111
87
:::note
112
88
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).
113
89
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:
- check client certificate has matching CN for a user:
117
93
- 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"]}`)
119
95
120
96
:::
121
97
122
98
123
99
## Configuration {#configuration}
124
100
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.
126
102
Major configuration parameters are defined in one scope (client or operation) and do not override each other.
127
103
128
104
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.
189
165
190
166
### ClickHouseFormat {#clickhouseformat}
191
167
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.
193
169
194
-
*`raw` - user should transcode raw data
170
+
*`raw` - user should transcode raw data
195
171
*`full` - the client can transcode data by itself and accepts a raw data stream
196
172
*`-` - operation not supported by ClickHouse for this format
`data` - collection DTO (Data Transfer Object) objects.
343
319
@@ -379,7 +355,7 @@ Configuration options for insert operations.
379
355
380
356
### InsertResponse {#insertresponse}
381
357
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.
383
359
384
360
:::note
385
361
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.
`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.
409
385
410
386
`settings` - request settings.
411
387
412
388
**Return value**
413
389
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.
`sqlQuery` - sql expression with placeholders `{}`.
431
+
`sqlQuery` - sql expression with placeholders `{}`.
456
432
457
433
`queryParams` - map of variables to complete the sql expression on server.
458
434
459
-
`settings` - request settings.
435
+
`settings` - request settings.
460
436
461
437
**Return value**
462
438
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.
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.
507
483
508
484
**Examples**
509
485
@@ -546,7 +522,7 @@ Configuration options for query operations.
546
522
547
523
### QueryResponse {#queryresponse}
548
524
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.
550
526
551
527
:::note
552
528
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.
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`.
0 commit comments