Skip to content

Batch insert failed #2370

Open
Open

Description

@ducklikeeat

Company or project name

No response

Question

Why does the SQL in my XML file execute normally when inserted individually, but an error occurs when executed in batches, and the error code is -2, and I can't tell where the problem lies?

Activity

  1. ducklikeeat commented on May 16, 2025

    @ducklikeeat
    Author
    INSERT INTO mq_log.t_supply_available_hotel ( supplier_id, sp_hotel_id, check_in, check_out, search_date, create_time ) values ( #{item.supplierId}, #{item.spHotelId}, #{item.checkIn,jdbcType=DATE}, #{item.checkOut,jdbcType=DATE}, #{item.searchDate,jdbcType=DATE}, #{item.createTime,jdbcType=TIMESTAMP} ) this is my xml
  2. added
    jdbc
    on May 16, 2025
  3. chernser commented on May 16, 2025

    @chernser
    Contributor

    Good day, @ducklikeeat!
    What version of the JDBC do you use?
    what library version do you use?
    what framework do you use?
    would you please share a sample code to understand how XML gets into a statement?

    I think this is because we do not support constructions like #{item.checkIn,jdbcType=DATE} in the V2 JDBC because they are not defined in the spec.

    Thanks!

  4. added this to the 0.9.1 milestone on Jun 10, 2025
  5. removed this from the 0.9.1 milestone on Jun 25, 2025
  6. github-actions commented on Jul 13, 2026

    @github-actions

    This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

  7. added this to the 0.12.0 milestone on Jul 22, 2026
  8. removed this from the 0.12.0 milestone on Nov 10, 2026
  9. added
    queries
    and removed on Nov 26, 2026
  10. polyglotAI-bot commented on Nov 28, 2026

    @polyglotAI-bot
    Collaborator

    Recommendation: Close — no response
    The reporter did not answer the request of 2025-05-16 for the driver version, the framework, and the code. Without the error text, the cause of the -2 is not known.

    • Category: Question
    • Classification: impact: none · area: Queries (batch inserts)
    • Status on main: Not applicable — at 8480ca001, ClickHouse 26.11.4.11, the statement that MyBatis makes from the issue's XML for two items (two rows of ? markers, one addBatch()) stores both rows, and executeBatch() returns [2].
    • Breaking change: No
    • Duplicates / related: None found

    Analysis: MyBatis replaces each #{…}, also with jdbcType=DATE, with a ? marker before it calls the driver, so the driver does not see that syntax. -2 is the value of Statement.SUCCESS_NO_INFO: jdbc-v2 returns it from executeBatch() when the row count of the server differs from the number of batch entries (jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java:378-382). The issue does not say if the -2 is such a return value or the code of an exception.

    Automated triage by Polyglot AI. A maintainer makes the final decision.

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

    jdbcqueriesquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions