Skip to content

flight-sql-jdbc-driver throws "parameter ordinal 1 out of range" for PreparedStatement in SELECT query #1009

Closed as duplicate

Description

@eqrvivek

Describe the usage question you have. Please include as many useful details as possible.

I am using the flight-sql-jdbc-driver (version 18.x / Doris 3.x) and I am trying to execute a simple SELECT query with a PreparedStatement and a ? placeholder. However, I consistently get the following exception:

java.sql.SQLException: parameter ordinal 1 out of range

Here is the minimal example of the code :

import java.sql.*;

public class DorisTest
{
public static void main(String[] args) throws Exception {
// Connect to Doris Flight SQL
String url = "jdbc:apache:arrow:flight://host:port";
Connection conn = DriverManager.getConnection(url);

    // SQL with a single parameter
    String sql = "SELECT * FROM Connectors WHERE connectorID = ?";
    PreparedStatement ps = conn.prepareStatement(sql);
    ps.setInt(1, 1); // This line throws SQLException

    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
        System.out.println(rs.getInt("connectorID"));
    }

    conn.close();
 }

}

The driver throws: java.sql.SQLException: parameter ordinal 1 out of range

Additional observations:

  1. PreparedStatement is obtained directly from the JDBC connection.
  2. PreparedStatement.getParameterMetaData() seems to return 0 parameters.
  3. The driver works fine for queries without placeholders or with inline values.
  4. The Flight SQL JDBC driver appears to not support ? placeholders reliably in this version.

Question:

  1. Is this a known limitation of the Doris Flight SQL JDBC driver?
  2. Are there any workarounds to use PreparedStatement with parameters for SELECT queries?
  3. If placeholders are not supported, what is the recommended way to safely execute parameterized queries (especially for IN clauses with multiple
    values) in Doris Flight SQL JDBC driver?

Any guidance or best practices would be greatly appreciated!

Activity

  1. lidavidm commented on Feb 6, 2026

    @lidavidm
    Member

    Duplicate of #121?

  2. eqrvivek commented on Feb 6, 2026

    @eqrvivek
    Author

    i went through the issue details. How do i set parameter_schema? Is there any documentation i can use?

  3. lidavidm commented on Feb 6, 2026

    @lidavidm
    Member

    That is a server-side implementation issue.

  4. eqrvivek commented on Feb 6, 2026

    @eqrvivek
    Author

    ok so right now, we can not use placeholders? and what does server side implementation means and how it can be fixed?

  5. ennuite commented on Feb 9, 2026

    @ennuite
    Contributor

    @eqrvivek you can use placeholders with a compatible server side implementation.
    This is not the Doris Flight SQL JDBC driver. There are multiple possible server side implementations with varying degrees of protocol (Flight SQL) implementation. Doris seems to not fully implement the protocol.

    You should open an issue there. The code in this repo is not the problem.

  6. ennuite commented on Feb 23, 2026

    @ennuite
    Contributor

    @lidavidm can we close this?

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions