Skip to content

IllegalArgumentException caused by local default datetime when using nullAsDefault property #1735

Closed

Description

@yanye666

Still got this problem in version:0.3.2-patch11, When I set 0 or null timestamp to ClickHouse DataTime column,I got this err

DateTime(-28800) should between 0 and 4294967295000 inclusive of both values

Originally posted by @cod-soap in #999 (comment)

Activity

  1. yanye666 commented on Jul 16, 2024

    @yanye666
    Author

    When I set the object property string to "1970-01-01 00:00:00" ,throw exception,below the debug

    image

    When I set the object property string to "1970-01-01 08:00:00" ,avoid exception,database query show
    image

  2. added
    investigating
    on Jul 16, 2024
  3. chernser commented on Jul 16, 2024

    @chernser
    Contributor

    Good day, @yanye666 !

    How do you set null timestamp?

    Here is my code that works for latest version 0.6.2

     try (ClickHouseConnection conn = newConnection(props);
                    PreparedStatement ps = conn.prepareStatement("select toDateTime(?)")) {
    
                ps.setTimestamp(1, null);
                ResultSet rs = ps.executeQuery();
                Assert.assertTrue(rs.next());
                Assert.assertNull(rs.getObject(1));
            }
    

    Thanks!

  4. yanye666 commented on Jul 17, 2024

    @yanye666
    Author

    Good day, @yanye666 !

    How do you set null timestamp?

    Here is my code that works for latest version 0.6.2

    
     try (ClickHouseConnection conn = newConnection(props);
    
                    PreparedStatement ps = conn.prepareStatement("select toDateTime(?)")) {
    
    
    
                ps.setTimestamp(1, null);
    
                ResultSet rs = ps.executeQuery();
    
                Assert.assertTrue(rs.next());
    
                Assert.assertNull(rs.getObject(1));
    
            }
    
    

    Thanks!

    I'm not set null.I want to insert the default 1970 timestamp to avoid clickhouse nullable. But as shown in the figure, I have to set 1970-01-01 08:00:00, otherwise I will report an error.Inspection of the first diagram

  5. added
    client
    data-types
    on Jan 9, 2025
  6. added
    jdbc
    client
    and removed
    client
    on Jan 27, 2025
  7. chernser commented on Jan 27, 2025

    @chernser
    Contributor

    @yanye666 this is the problem with timezone and Dates.
    This check is valid because it prevents writing dates before 1970-01-01 00:00:00. But as you are in Tz +8 it means that passed date is ahead of UTC by 8h and when it is converted into UTC it will be before 1970-01-01 00:00:00.

  8. added
    documentation
    and removed
    investigating
    on Jan 27, 2025
  9. modified the milestone: 0.9.2 on Jul 23, 2025
  10. 1 remaining item

  11. self-assigned this
    on Jul 24, 2025
  12. added this to the 0.9.3 milestone on Aug 20, 2025
  13. modified the milestones: 0.9.3, 0.9.4 on Oct 1, 2025
  14. modified the milestones: 0.9.5, 0.9.6, 0.9.7 on Jan 6, 2026
  15. modified the milestones: 0.9.7, 0.9.8 on Jan 21, 2026
  16. chernser commented on Feb 26, 2026

    @chernser
    Contributor

    Good day, @yanye666 !

    For the upcoming 0.9.7 we have created a document about date/time value https://clickhouse.com/docs/integrations/language-clients/java/jdbc_date_time_guide It should add clarity.
    Also we removed come conversions to make writing/reading values more transparent.

    Thanks!

  17. modified the milestones: 0.9.8, 0.9.7 on Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugclientdata-typesdocumentationjdbc

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions