镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Clickhouse jdbc-v2: Prepared Statement not working when column names like "ip" or "url" appear in query #2617

Closed

Description

@adityam31

Description

If the query contains column names like "ip" or "url" then PreparedStatement 's setObject() or any set methods throw java.lang.ArrayIndexOutOfBoundException

Steps to reproduce

  1. Create a simple table in clickhouse CREATE TABLE myusers ( id UInt64, ip String, url String, tenant String) ENGINE = MergeTree() PRIMARY KEY (id);
  2. Write a simple query "select ip from myusers where tenant=?" in java code
  3. Use connection.prepareStatement(query) to generate PreparedStatement object
  4. Call setObject(1,1) on prepare statement object
Image Image

same observed for url

Image

Error Log or Exception StackTrace

java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at com.clickhouse.jdbc.PreparedStatementImpl.setObject(PreparedStatementImpl.java:291)

Expected Behaviour

It should allow setting objects in PreparedStatement without exception

Code Example

String query = "select ip from myusers where tenant=?";
PreparedStatement ps = connection.prepareStatement(query);
ps.setObject(1, 1);

Configuration

Client Configuration

<dependency>
    <groupId>com.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.9.2</version>
    <classifier>all</classifier>
</dependency>

and also observed same for 0.9.1 version

<dependency>
    <groupId>com.clickhouse</groupId>
    <artifactId>clickhouse-jdbc</artifactId>
    <version>0.9.1</version>
    <classifier>all</classifier>
</dependency>

Environment

  • Cloud
  • Client version: java jdbc v2 0.9.2 and 0.9.1
  • Language version: Java 17
  • OS:

ClickHouse Server

  • ClickHouse Server version: 25.3.6.56-lts
  • ClickHouse Server non-default settings, if any:
  • CREATE TABLE statements for tables involved:
  • Sample data for all these tables, use clickhouse-obfuscator if necessary

Activity

  1. changed the title [-]Clickhouse JDBC Prepared Statement not working when column names like "ip" or "url" are contained in query[/-] [+]Clickhouse JDBC Prepared Statement not working when column names like "ip" or "url" appear in query[/+] on Oct 17, 2025
  2. changed the title [-]Clickhouse JDBC Prepared Statement not working when column names like "ip" or "url" appear in query[/-] [+]Clickhouse JDBC v2 : Prepared Statement not working when column names like "ip" or "url" appear in query[/+] on Oct 17, 2025
  3. changed the title [-]Clickhouse JDBC v2 : Prepared Statement not working when column names like "ip" or "url" appear in query[/-] [+]Clickhouse jdbc-v2: Prepared Statement not working when column names like "ip" or "url" appear in query[/+] on Oct 17, 2025
  4. added this to the 0.9.3 milestone on Oct 20, 2025
  5. chernser commented on Oct 20, 2025

    @chernser
    Contributor

    Good day, @adityam31 !
    Thank you for reporting!

    We will fix it!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions