Skip to content

Commit 1dc7e0f

Browse files
committed
added more information. fixed links
1 parent 005b656 commit 1dc7e0f

File tree

2 files changed

+46
-6
lines changed

2 files changed

+46
-6
lines changed

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

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Configuration is defined during client creation. See `com.clickhouse.client.api.
167167
| `setConnectionRequestTimeout(long timeout, ChronoUnit unit)` | `timeout` - timeout value<br/>`unit` - time unit | Sets connection request timeout. This take effect only for getting connection from a pool. | `10000` | `connection_request_timeout` |
168168
| `setSocketTimeout(long timeout, ChronoUnit unit)` | `timeout` - timeout value<br/>`unit` - time unit | Sets socket timeout that affects read and write operations | `0` | `socket_timeout` |
169169
| `setExecutionTimeout(long timeout, ChronoUnit timeUnit)` | `timeout` - timeout value<br/>`timeUnit` - time unit | Sets maximum execution timeout for queries | `0` | `max_execution_time` |
170-
| `retryOnFailures(ClientFaultCause ...causes)` | `causes` - enum constant of `ClientFaultCause` | Sets recoverable/retriable fault types. | `NoHttpResponse,ConnectTimeout,ConnectionRequestTimeout` | `client_retry_on_failures` |
170+
| `retryOnFailures(ClientFaultCause ...causes)` | `causes` - enum constant of `ClientFaultCause` | Sets recoverable/retriable fault types. | `NoHttpResponse` `ConnectTimeout` `ConnectionRequestTimeout` | `client_retry_on_failures` |
171171
| `setMaxRetries(int maxRetries)` | `maxRetries` - number of retries | Sets maximum number of retries for failures defined by `retryOnFailures` | `3` | `retry` |
172172

173173
</TabItem>
@@ -293,7 +293,7 @@ Server side settings can be set on the client level once while creation (see `se
293293
...
294294
}
295295
```
296-
When options are set via `setOption` method (either the `Client.Builder` or operation settings class) then server settings name should be prefixed with `clickhouse_setting_`. The `com.clickhouse.client.api.ClientConfigProperties#serverSetting()` may be handy in this case.
296+
⚠️ When options are set via `setOption` method (either the `Client.Builder` or operation settings class) then server settings name should be prefixed with `clickhouse_setting_`. The `com.clickhouse.client.api.ClientConfigProperties#serverSetting()` may be handy in this case.
297297

298298
### Custom HTTP Header
299299

@@ -760,7 +760,7 @@ Complete examples code is stored in the repo in a 'example` [folder](https://git
760760
- [demo-service](https://github.com/ClickHouse/clickhouse-java/tree/main/examples/demo-service) - example of how to use the client in a Spring Boot application.
761761
- [demo-kotlin-service](https://github.com/ClickHouse/clickhouse-java/tree/main/examples/demo-kotlin-service) - example of how to use the client in Ktor (Kotlin) application.
762762

763-
## Migration From V1 ( =< 0.7.x ) {#migration_from_v1}
763+
## Migration Guide {#migration_guide}
764764

765765

766766
Old client (V1) was using `com.clickhouse.client.ClickHouseClient#builder` as start point. The new client (V2) uses similar pattern with `com.clickhouse.client.api.Client.Builder`. Main
@@ -1006,9 +1006,36 @@ executor (see `com.clickhouse.client.api.Client.Builder#setSharedOperationExecut
10061006
- use any implementation of `java.io.InputStream`. V1 `com.clickhouse.data.ClickHouseInputStream` is supported but NOT recommended.
10071007
- once end of input stream is detected it handled accordingly. Previously output stream of a request should be closed.
10081008

1009+
__V1 Insert TSV formatted data.__
10091010
```java
1011+
InputStream inData = getInData();
1012+
ClickHouseRequest.Mutation request = client.read(server)
1013+
.write()
1014+
.table(tableName)
1015+
.format(ClickHouseFormat.TSV);
1016+
ClickHouseConfig config = request.getConfig();
1017+
CompletableFuture<ClickHouseResponse> future;
1018+
try (ClickHousePipedOutputStream requestBody = ClickHouseDataStreamFactory.getInstance()
1019+
.createPipedOutputStream(config)) {
1020+
// start the worker thread which transfer data from the input into ClickHouse
1021+
future = request.data(requestBody.getInputStream()).execute();
1022+
1023+
// Copy data from inData stream to requestBody stream
1024+
1025+
// We need to close the stream before getting a response
1026+
requestBody.close();
1027+
1028+
try (ClickHouseResponse response = future.get()) {
1029+
ClickHouseResponseSummary summary = response.getSummary();
1030+
Assert.assertEquals(summary.getWrittenRows(), numRows, "Num of written rows");
1031+
}
1032+
}
1033+
1034+
```
1035+
1036+
__V2 Insert TSV formatted data.__
10101037

1011-
// V2 Insert TSV formatted data.
1038+
```java
10121039
InputStream inData = getInData();
10131040
InsertSettings settings = new InsertSettings().setInputStreamCopyBufferSize(8198 * 2); // set copy buffer size
10141041
try (InsertResponse response = client.insert(tableName, inData, ClickHouseFormat.TSV, settings).get(30, TimeUnit.SECONDS)) {
@@ -1019,7 +1046,8 @@ try (InsertResponse response = client.insert(tableName, inData, ClickHouseFormat
10191046
// Handle exception
10201047
}
10211048
```
1022-
1049+
- there is a single method to call. No need to create an additional request object.
1050+
- request body stream is closed automatically when all data is copied.
10231051
- new low-level API is available `com.clickhouse.client.api.Client#insert(java.lang.String, java.util.List<java.lang.String>, com.clickhouse.client.api.DataStreamWriter, com.clickhouse.data.ClickHouseFormat, com.clickhouse.client.api.insert.InsertSettings)`. `com.clickhouse.client.api.DataStreamWriter` is designed to implement custom data writing logic. For instance, reading data from a
10241052
queue.
10251053

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,23 @@ Where possible methods will return an `SQLFeatureNotSupportedException` if the f
108108
:::note Server Settings
109109

110110
All server settings should be prefixed with `clickhouse_setting_` (same as for the client [configuration](/integrations/language-clients/java/client#server-settings)).
111+
112+
113+
```java
114+
Properties config = new Properties();
115+
config.setProperty("user", "default");
116+
config.setProperty("password", getPassword());
117+
118+
// set server setting
119+
config.put(ClientConfigProperties.serverSetting("allow_experimental_time_time64_type"), "1");
120+
121+
Connection conn = Driver.connect("jdbc:ch:http://localhost:8123/", config);
122+
```
111123
:::
112124

113125
## Supported data types {#supported-data-types}
114126

115-
JDBC Driver supports the same data formats as the underlying [java client](/integrations/language-clients/java/client/client.mdx).
127+
JDBC Driver supports the same data formats as the underlying [java client](/integrations/java#supported-data-types).
116128

117129
### Handling Dates, Times, and Timezones {#handling-dates-times-and-timezones}
118130
`java.sql.Date`, `java.sql.Time`, and `java.sql.Timestamp` can complicate how Timezones are calculated - though they're of course supported,

0 commit comments

Comments
 (0)