Open lukaseder opened 6 months ago
Workaround: Use java.time.LocalDate[]
instead:
try (PreparedStatement s = connection.prepareStatement("insert into t values (1, ?, ?)")) {
s.setObject(1, new LocalDate[] { LocalDate.parse("2000-01-01") });
s.setDate(2, Date.valueOf("2000-01-01"));
s.executeUpdate();
}
@lukaseder thank you for reporting the issue.
I encountered the same issue when using the java.sql.PreparedStatement.setObject() function with a column that has a Date data type. Here is my debugging:
create table t (a int, b date) engine = MergeTree order by a;
insert into t (a, b) values (1, '2025-08-18'), (2, 2025-08-18);
I can insert a date value without using single quote wrappers, and it won't cause any errors.
select a, b from t;
The result is:
a | b |
---|---|
1 | 2025-08-18 |
2 | 1975-06-23 |
Different values are present in the b column.
I am using ClickHouse JDBC version 0.5.0 with ClickHouse server version 23.10.3.5.
com.clickhouse.jdbc.ClickHouseConnection#createArrayOf
Describe the bug
When inserting a
Date[]
Java type into anArray(Date)
column, then a wrong value is being inserted.Steps to reproduce
Create this table:
Then run this program:
Now, validate the results:
The scalar date is correct, but the date array isn't:
I'm running this in CEST time zone, in case this matters.
Expected behaviour
The expoected result is:
(The formatting is from Dbeaver and can be ignored)
Configuration
Environment
com.clickhouse:clickhouse-jdbc:0.6.0-patch4
ClickHouse server