Skip to content

Commit

Permalink
Merge pull request #2942 from ClickHouse/java_client_0.7.2_update
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerwizard authored Dec 28, 2024
2 parents d937c93 + 183acac commit ad42532
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
10 changes: 6 additions & 4 deletions docs/en/integrations/language-clients/java/client-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import CodeBlock from '@theme/CodeBlock';

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

*Note*: this component will be deprecated soon.
:::warning Deprecation
This library will be deprecated soon. Use Client-v2 for new projects
:::

## Setup

Expand All @@ -26,7 +28,7 @@ Java client library to communicate with a DB server thru its protocols. Current
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-http-client</artifactId>
<version>0.7.1</version>
<version>0.7.2</version>
</dependency>
```

Expand All @@ -35,14 +37,14 @@ Java client library to communicate with a DB server thru its protocols. Current

```kotlin
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client
implementation("com.clickhouse:clickhouse-http-client:0.7.1")
implementation("com.clickhouse:clickhouse-http-client:0.7.2")
```
</TabItem>
<TabItem value="gradle" label="Gradle">

```groovy
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-http-client
implementation 'com.clickhouse:clickhouse-http-client:0.7.1'
implementation 'com.clickhouse:clickhouse-http-client:0.7.2'
```

</TabItem>
Expand Down
40 changes: 23 additions & 17 deletions docs/en/integrations/language-clients/java/client-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Java client library to communicate with a DB server through its protocols. The c
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>client-v2</artifactId>
<version>0.7.1</version>
<version>0.7.2</version>
</dependency>
```

Expand All @@ -35,14 +35,14 @@ Java client library to communicate with a DB server through its protocols. The c

```kotlin
// https://mvnrepository.com/artifact/com.clickhouse/client-v2
implementation("com.clickhouse:client-v2:0.7.1")
implementation("com.clickhouse:client-v2:0.7.2")
```
</TabItem>
<TabItem value="gradle" label="Gradle">

```groovy
// https://mvnrepository.com/artifact/com.clickhouse/client-v2
implementation 'com.clickhouse:client-v2:0.7.1'
implementation 'com.clickhouse:client-v2:0.7.2'
```

</TabItem>
Expand Down Expand Up @@ -157,7 +157,7 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
| setServerTimeZone(String timeZone) | `timeZone` - string value of java valid timezone ID (see `java.time.ZoneId`) | Sets server side timezone. UTC timezone will be used by default. |
| useAsyncRequests(boolean async) | `async` - flag that indicates if the option should be enabled. | Sets if client should execute request in a separate thread. Disabled by default because application knows better how to organize multithreaded tasks and running tasks in separate thread do not help with performance. |
| setSharedOperationExecutor(ExecutorService executorService) | `executorService` - instance of executor service. | Sets executor service for operation tasks. |
| setClientNetworkBufferSize(int size) | - `size` - size in bytes | Sets size of a buffer in application memory space that is used to copy data back-and-forth between socket and application. Greater reduces system calls to TCP stack, but affects how much memory is spent on every connection. This buffer is also subject for GC because connections are shortlive. Also keep in mind that allocating big continious block of memory might be a problem. |
| setClientNetworkBufferSize(int size) | - `size` - size in bytes | Sets size of a buffer in application memory space that is used to copy data back-and-forth between socket and application. Greater reduces system calls to TCP stack, but affects how much memory is spent on every connection. This buffer is also subject for GC because connections are shortlive. Also keep in mind that allocating big continious block of memory might be a problem. Default is `300,000` bytes. |
| retryOnFailures(ClientFaultCause ...causes) | - `causes` - enum constant of `com.clickhouse.client.api.ClientFaultCause` | Sets recoverable/retriable fault types. |
| setMaxRetries(int maxRetries) | - `maxRetries` - number of retries | Sets maximum number of retries for failures defined by `retryOnFailures(ClientFaultCause ...causes)` |
| allowBinaryReaderToReuseBuffers(boolean reuse) | - `reuse` - flag that indicates if the option should be enabled | Most datasets contain numeric data encoded as small byte sequences. By default reader will allocate required buffer, read data into it and then transform into a target Number class. That may cause significant GC preasure because of many small objects are being allocated and released. If this option is enabled then reader will use preallocated buffers to do numbers transcoding. It is safe because each reader has own set of buffers and readers are used by one thread. |
Expand All @@ -168,7 +168,8 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
| serverSetting(String name, Collection values) | - `name` - name of a query level setting.<br /> - `values` - string values of the setting. |Sets what settings to pass to server along with each query. Individual operation settings may override it. The [List of settings](/docs/en/operations/settings/query-level). This method is useful to set settings with multiple values, for example [roles](/docs/en/interfaces/http#setting-role-with-query-parameters) |
| columnToMethodMatchingStrategy(ColumnToMethodMatchingStrategy strategy) | - `strategy` - implementation of a column-field matching strategy | Sets custom strategy to be used for matching DTO class fields and DB columns when registering DTO. |
| useHTTPBasicAuth(boolean useBasicAuth) | - `useBasicAuth` - flag that indicates if the option should be enabled | Sets if basic HTTP authentication should be used for user-password authentication. Default is enabled. Using this type of authentication resolves issues with passwords containing special characters that cannot be transferred over HTTP headers. |

| setClientName(String clientName) | - `clientName` - a string representing application name | Sets additional information about calling application. This string will be passed to server as a client name. In case of HTTP protocol it will be passed as a `User-Agent` header. |
| useBearerTokenAuth(String bearerToken) | - `bearerToken` - an encoded bearer token | Specifies whether to use Bearer Authentication and what token to use. The token will be sent as is, so it should be encoded before passing to this method. |

## Common Definitions

Expand Down Expand Up @@ -354,22 +355,25 @@ Configuration options for insert operations.

<dl>
<dt>setQueryId(String queryId)</dt>
<dd>Sets query ID that will be assigned to the operation. Default: null</dd>
<dd>Sets query ID that will be assigned to the operation. Default: `null`.</dd>

<dt>setDeduplicationToken(String token)</dt>
<dd>Sets the deduplication token. This token will be sent to the server and can be used to identify the query. Default: null</dd>
<dd>Sets the deduplication token. This token will be sent to the server and can be used to identify the query. Default: `null`.</dd>

<dt>setInputStreamCopyBufferSize(int size)</dt>
<dd>Copy buffer size. The buffer is used during write operations to copy data from user provided input stream to an output stream. Default: 8196</dd>
<dd>Copy buffer size. The buffer is used during write operations to copy data from user provided input stream to an output stream. Default: `8196`.</dd>

<dt>serverSetting(String name, String value)</dt>
<dd>Sets individual server settings for an operation</dd>
<dd>Sets individual server settings for an operation.</dd>

<dt>serverSetting(String name, Collection values)</dt>
<dd>Sets individual server settings with multiple values for an operation. Items of the collection should `String` values</dd>
<dd>Sets individual server settings with multiple values for an operation. Items of the collection should `String` values.</dd>

<dt>setDBRoles(Collection dbRoles)</dt>
<dd>Sets DB roles to be set before executing an operation. Items of the collection should be `String` values</dd>
<dd>Sets DB roles to be set before executing an operation. Items of the collection should be `String` values.</dd>

<dt>setOption(String option, Object value)</dt>
<dd>Sets a configuration option in raw format. This is not a server setting.</dd>
</dl>

### InsertResponse
Expand All @@ -382,7 +386,7 @@ This object should be closed as soon as possible to release a connection because

<dl>
<dt>OperationMetrics getMetrics()</dt>
<dd>Returns object with operation metrics</dd>
<dd>Returns object with operation metrics.</dd>
<dt>String getQueryId()</dt>
<dd>Returns query ID assigned for the operation by application (thru operation settings or by server).</dd>
</dl>
Expand Down Expand Up @@ -530,23 +534,25 @@ Configuration options for query operations.

<dl>
<dt>setQueryId(String queryId)</dt>
<dd>Sets query ID that will be assigned to the operation</dd>
<dd>Sets query ID that will be assigned to the operation.</dd>
<dt>setFormat(ClickHouseFormat format)</dt>
<dd>Sets response format. See `RowBinaryWithNamesAndTypes` for the full list.</dd>
<dt>setMaxExecutionTime(Integer maxExecutionTime)</dt>
<dd>Sets operation execution time on server. Will not affect read timeout.</dd>
<dt>waitEndOfQuery(Boolean waitEndOfQuery)</dt>
<dd>Requests the server to wait for the and of the query before sending response.</dd>
<dt>setUseServerTimeZone(Boolean useServerTimeZone)</dt>
<dd>Server timezone (see client config) will be used to parse date/time types in the result of an operation. Default `false`</dd>
<dd>Server timezone (see client config) will be used to parse date/time types in the result of an operation. Default `false`.</dd>
<dt>setUseTimeZone(String timeZone)</dt>
<dd>Requests server to use `timeZone` for time conversion. See <a href="/docs/en/operations/settings/settings#session_timezone" target="_blank">session_timezone</a>.</dd>
<dt>serverSetting(String name, String value)</dt>
<dd>Sets individual server settings for an operation</dd>
<dd>Sets individual server settings for an operation.</dd>
<dt>serverSetting(String name, Collection values)</dt>
<dd>Sets individual server settings with multiple values for an operation. Items of the collection should `String` values</dd>
<dd>Sets individual server settings with multiple values for an operation. Items of the collection should `String` values.</dd>
<dt>setDBRoles(Collection dbRoles)</dt>
<dd>Sets DB roles to be set before executing an operation. Items of the collection should be `String` values</dd>
<dd>Sets DB roles to be set before executing an operation. Items of the collection should be `String` values.</dd>
<dt>setOption(String option, Object value)</dt>
<dd>Sets a configuration option in raw format. This is not a server setting.</dd>
</dl>

### QueryResponse
Expand Down
10 changes: 5 additions & 5 deletions docs/en/integrations/language-clients/java/jdbc-driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import CodeBlock from '@theme/CodeBlock';
`clickhouse-jdbc` implements the standard JDBC interface. Being built on top of [clickhouse-client](/docs/en/integrations/sql-clients/sql-console), it provides additional features like custom type mapping, transaction support, and standard synchronous `UPDATE` and `DELETE` statements, etc., so that it can be easily used with legacy applications and tools.

:::note
Latest JDBC (0.7.1) version uses Client-V1
Latest JDBC (0.7.2) version uses Client-V1
:::

`clickhouse-jdbc` API is synchronous, and generally, it has more overheads(e.g., SQL parsing and type mapping/conversion, etc.). Consider [clickhouse-client](/docs/en/integrations/sql-clients/sql-console) when performance is critical or if you prefer a more direct way to access ClickHouse.
Expand All @@ -36,9 +36,9 @@ import CodeBlock from '@theme/CodeBlock';
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.7.1</version>
<version>0.7.2</version>
<!-- use uber jar with all dependencies included, change classifier to http for smaller jar -->
<classifier>all</classifier>
<classifier>shaded-all</classifier>
</dependency>
```

Expand All @@ -48,15 +48,15 @@ import CodeBlock from '@theme/CodeBlock';
```kotlin
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc
// use uber jar with all dependencies included, change classifier to http for smaller jar
implementation("com.clickhouse:clickhouse-jdbc:0.7.1:all")
implementation("com.clickhouse:clickhouse-jdbc:0.7.2:shaded-all")
```
</TabItem>
<TabItem value="gradle" label="Gradle">

```groovy
// https://mvnrepository.com/artifact/com.clickhouse/clickhouse-jdbc
// use uber jar with all dependencies included, change classifier to http for smaller jar
implementation 'com.clickhouse:clickhouse-jdbc:0.7.1:all'
implementation 'com.clickhouse:clickhouse-jdbc:0.7.2:shaded-all'
```

</TabItem>
Expand Down

0 comments on commit ad42532

Please sign in to comment.