Skip to content

[jdbc] Incorrect DateTime results when writing numeric data with use_time_zone property #2065

Open
@haishui126

Description

@haishui126

Describe the bug

The DateTime results will -8h when inserting long values using PrepareStatement with use_server_time_zone=false&use_time_zone=Asia/Shanghai. (ClickHouse Server timezone is UTC)

Expected: '1970-01-01 08:00:00.001000000'
Actual: '1970-01-01 00:00:00.001000000'
(timezone is Asia/Shanghai)

Code example

CREATE TABLE t_test
(
    `timestamp` DateTime64(3)
)
ENGINE = Log;
try (
    Connection connection = DriverManager.getConnection("jdbc:ch://localhost:8123/default?use_server_time_zone=false&use_time_zone=Asia/Shanghai", "default", "");
    PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO t_test VALUES (?)")
) {
    preparedStatement.setLong(1, 1);
    preparedStatement.execute();
}

Configuration

Environment

  • Client version: 0.7.2
  • Language version: java11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugdata-typedata type processing issuesjdbc-v2jdbc-v2 issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions