-
Notifications
You must be signed in to change notification settings - Fork 111
Open
Labels
Type: usageusage questionusage question
Description
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:
- PreparedStatement is obtained directly from the JDBC connection.
- PreparedStatement.getParameterMetaData() seems to return 0 parameters.
- The driver works fine for queries without placeholders or with inline values.
- The Flight SQL JDBC driver appears to not support ? placeholders reliably in this version.
Question:
- Is this a known limitation of the Doris Flight SQL JDBC driver?
- Are there any workarounds to use PreparedStatement with parameters for SELECT queries?
- 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!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type: usageusage questionusage question