From f2385cd2a2d06850ac3bda695748d5b5a3dd2daf Mon Sep 17 00:00:00 2001 From: Luke Gannon Date: Wed, 25 Nov 2026 17:25:49 +0000 Subject: [PATCH] jdbc-v2: interpret setObject(LocalDateTime) in the server time zone on the text path A LocalDateTime bound via setObject on the text path was converted to an instant using the JVM default time zone, so the stored value depended on the JVM's zone. A LocalDateTime has no instant; its fields should be interpreted in the column or server time zone, like Timestamp and a string literal already are. encodeObject now renders a LocalDateTime as a quoted wall-clock string instead of fromUnixTimestamp64Nano(..., JVM zone). The old JVM-zone behaviour is available via the new jdbc_legacy_localdatetime_jvm_timezone property (default false). Fixes #3127 Co-Authored-By: Claude Opus 4.8 --- history/latest/3127.md | 4 +++ .../com/clickhouse/jdbc/DriverProperties.java | 6 ++++ .../jdbc/PreparedStatementImpl.java | 7 ++++- .../clickhouse/jdbc/JDBCDateTimeTests.java | 30 +++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 history/latest/3127.md diff --git a/history/latest/3127.md b/history/latest/3127.md new file mode 100644 index 0000000000..ed79971571 --- /dev/null +++ b/history/latest/3127.md @@ -0,0 +1,4 @@ +- **[jdbc-v2]** A `LocalDateTime` bound via `setObject` on the text path is now interpreted in the + server/column time zone instead of the JVM default time zone, matching `Timestamp` and the reader. + Behaviour change on a non-UTC JVM; set `jdbc_legacy_localdatetime_jvm_timezone=true` to restore the + old behaviour. (https://github.com/ClickHouse/clickhouse-java/issues/3127) diff --git a/jdbc-v2/src/main/java/com/clickhouse/jdbc/DriverProperties.java b/jdbc-v2/src/main/java/com/clickhouse/jdbc/DriverProperties.java index 8bbcfd10b3..b6abddd465 100644 --- a/jdbc-v2/src/main/java/com/clickhouse/jdbc/DriverProperties.java +++ b/jdbc-v2/src/main/java/com/clickhouse/jdbc/DriverProperties.java @@ -72,6 +72,12 @@ public enum DriverProperties { + "max_result_rows with result_overflow_mode=break. This overrides the overflow mode that the user sets.") USE_MAX_RESULT_ROWS("jdbc_use_max_result_rows", String.valueOf(Boolean.FALSE)), + @ConfigDescription("Legacy. When true, a LocalDateTime bound through setObject on the text path is " + + "converted using the JVM default time zone (the behaviour before the fix for issue #3127). " + + "The default false sends the local date-time unchanged, so the server interprets it in the " + + "column or server time zone, matching Timestamp and the reader.") + LEGACY_LOCALDATETIME_JVM_TIMEZONE("jdbc_legacy_localdatetime_jvm_timezone", String.valueOf(Boolean.FALSE)), + /** * Configures what SQL parser will be used. Choices: *