From 4254bc3cdb26266ec99ea33baa17dfc6be7f850c Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Wed, 17 Jun 2026 22:42:50 -0700 Subject: [PATCH 1/2] Added notes about readonly profiles and reading JSON type in JDBC --- .../language-clients/java/jdbc/jdbc.mdx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/docs/integrations/language-clients/java/jdbc/jdbc.mdx b/docs/integrations/language-clients/java/jdbc/jdbc.mdx index ab88e2f7e7f..350c73f1cf0 100644 --- a/docs/integrations/language-clients/java/jdbc/jdbc.mdx +++ b/docs/integrations/language-clients/java/jdbc/jdbc.mdx @@ -160,6 +160,12 @@ jdbc:ch:http://localhost:8123/?user=default&password=password&client_name=my-app ``` Note: no need to url encode JDBC URL or properties, they will be automatically encoded. +**Readonly Profiles** + +We deliberately avoid adding default settings to connection properties to avoid problems with read-only profiles. +However some users need to pass format settings (for example to read JSON as String) and we recommend using `readonly=2` profile. +Read more about read-only profiles [here](/operations/settings/settings-profiles#read-only). + ### Client Identification {#client-identification} There are two ways to identify application originated a request: set `com.clickhouse.client.api.ClientConfigProperties#CLIENT_NAME` via @@ -573,6 +579,58 @@ try (Connection conn = ...) { - `IPv4` and `IPv6` aren't JDBC standard types. However they're part of JDK. By default `java.net.Inet4Address` and `java.net.Inet6Address` are returned on `getObject()` method. - `IPv4` and `IPv6` can be read/written as `String` by using `getObject(columnIndex, String.class)` method. +**JSON Type** + +JSON type is mapped to Map by default where keys are JSON object keys and values are JSON object values. +For example: +```json +{ + "key1": "value1", + "key2": ["value2", "value3"] + "key3": { + "key4": "value4", + "key5": "value5" + } +} +``` +will be mapped to: + +```java +Map map = new HashMap<>(); +map.put("key1", "value1"); +map.put("key2", Arrays.asList("value2", "value3")); +map.put("key3", new HashMap() {{ + put("key4", "value4"); + put("key5", "value5"); +}}); +``` +There is more convinient option to read JSON as String by passing server setting `jdbc_read_json_as_string=true` to connection properties. +This makes driver return JSON values as String and can be used to parse using any JSON library. + +```java +Properties properties = new Properties(); +properties.setProperty( + ClientConfigProperties.serverSetting(ServerSettings.OUTPUT_FORMAT_BINARY_WRITE_JSON_AS_STRING), + "1"); +try (Connection conn = DriverManager.getConnection(url, properties)) { + try (ResultSet rs = stmt.executeQuery("SELECT * FROM test_json ORDER BY order")) { + while (rs.next()) { + String json = rs.getString("json"); + // ... + } + } +} +``` + +Starting ClickHouse version 25.8 numbers are no longer quoted by default. For older versions you can disable quoting by passing server settings to connection properties: +```java +Properties properties = new Properties(); +properties.put(ClientConfigProperties.serverSetting("output_format_json_quote_64bit_integers"), "0"); +properties.put(ClientConfigProperties.serverSetting("output_format_json_quote_64bit_floats"), "0"); +properties.put(ClientConfigProperties.serverSetting("output_format_json_quote_decimals"), "0"); +``` + + ### Handling Dates, Times, and Timezones {#handling-dates-times-and-timezones} Please read [Date/Time Guide](/integrations/language-clients/java/jdbc_date_time_guide) that explains common pitfalls From 6f629dd2299001e297687f1b93ce92711a9d04cd Mon Sep 17 00:00:00 2001 From: Dominic Tran Date: Thu, 18 Jun 2026 10:30:09 -0500 Subject: [PATCH 2/2] fix CI --- docs/integrations/language-clients/java/jdbc/jdbc.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/integrations/language-clients/java/jdbc/jdbc.mdx b/docs/integrations/language-clients/java/jdbc/jdbc.mdx index 350c73f1cf0..f66c18f7b5a 100644 --- a/docs/integrations/language-clients/java/jdbc/jdbc.mdx +++ b/docs/integrations/language-clients/java/jdbc/jdbc.mdx @@ -164,7 +164,7 @@ Note: no need to url encode JDBC URL or properties, they will be automatically e We deliberately avoid adding default settings to connection properties to avoid problems with read-only profiles. However some users need to pass format settings (for example to read JSON as String) and we recommend using `readonly=2` profile. -Read more about read-only profiles [here](/operations/settings/settings-profiles#read-only). +Read more about read-only profiles [here](/operations/settings/constraints-on-settings#read-only). ### Client Identification {#client-identification} @@ -581,7 +581,7 @@ try (Connection conn = ...) { **JSON Type** -JSON type is mapped to Map by default where keys are JSON object keys and values are JSON object values. +JSON type is mapped to `Map` by default where keys are JSON object keys and values are JSON object values. For example: ```json {