Skip to content

Setting timestamp as object fails in 0.3.1 #653

Closed

Description

@alniks

After upgrading to 0.3.1 I'm facing the following error:

ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 6, host: ip6-localhost, port: 8123; Code: 6, e.displayText() = DB::Exception: Cannot parse string '2021-05-06 09:59:19.475027700' as DateTime: syntax error at position 19 (parsed just '2021-05-06 09:59:19'): while executing 'FUNCTION CAST(assumeNotNull(_dummy_0) :: 2, 'DateTime' :: 1) -> CAST(assumeNotNull(_dummy_0), 'DateTime') DateTime : 4' (version 21.4.4.30 (official build)) , query: insert into transactional_events (transactional_id, type, email, user_id, info, domain_name, created_at, event_date) values (?, ?, ?, ?, ?, ?, ?, ?), params: 722310ea-877c-4b97-a97e-109ea4e60fe4, 2, test@contact.co, 209897, { "subject":"Before"}, contact.co, 2021-05-06 09:59:19.4750277, 2021-05-06 at org.javalite.activejdbc.DB.exec(DB.java:657)

the timestamp parameter is set as an Object:

PreparedStatement.setObject(index, param)

This worked fine in 0.2.6

Activity

  1. zhicwu commented on May 7, 2021

    @zhicwu
    Contributor

    Is the target column not DateTime64?

  2. alniks commented on May 7, 2021

    @alniks
    Author

    No, just DateTime

  3. added this to the 0.3.2 Release milestone on Jun 16, 2021
  4. linked a pull request that will close this issueEnhance new JDBC driver #765on Nov 29, 2021
  5. zhicwu commented on Dec 29, 2021

    @zhicwu
    Contributor

    Please try the new JDBC driver com.clickhouse.jdbc.ClickHouseDriver, which now has better support of DateTime values. Also please use java.time.LocalDateTime instead of java.sql.Timestamp, and use PrepareStatement.setObject to set value. There are a few examples at here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions