apache / apache/arrow-java

[Java][FlightRPC] Flight SQL JDBC driver parameter getting an exception: parameter ordinal 1 out of range

未关闭
#121 15 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
94
派生
152
平均合并
3 天 16 小时
30 天内合并 PR
11

描述

### Describe the bug, including details regarding any error messages, version, and platform.

```
protected AvaticaParameter getParameter(int param) throws SQLException {
try {
return (AvaticaParameter)this.getSignature().parameters.get(param - 1);
} catch (IndexOutOfBoundsException var3) {
throw AvaticaConnection.HELPER.toSQLException(AvaticaConnection.HELPER.createException("parameter ordinal " + param + " out of range"));
}
}
```

Getting this exception

My code:
```
public static void handleSqlStatements() throws SQLException {
String url = "jdbc:arrow-flight://localhost:5000;useEncryption=false;useServerPrepStmts=false;";
String sql = "select * from MixedTypeDB.`Table` where OID=?"; // Example SQL query
System.out.println("SQL query: " + sql); // Debugging: Log the query

try (var connection = DriverManager.getConnection(url)) {
ArrowFlightPreparedStatement pstmt = (ArrowFlightPreparedStatement)connection.prepareStatement(sql);
ParameterMetaData metadata = pstmt.getParameterMetaData();
pstmt.setInt(1, 12345); // crashing here

System.out.println("Executing SQL query: " + sql);

try (final ResultSet rs = pstmt.executeQuery()) {
}
} catch (SQLException e) {
e.printStackTrace();
}
}
```

```

org.apache.arrow
flight-sql-jdbc-driver
13.0.0

```

### Component(s)

Java

贡献指南

打开贡献指南

调研方向

从 issue 中所示的 getParameter(int param) 入口点开始,使用 Flight SQL JDBC URL、预准备查询和 setInt(1, 12345),通过 handleSqlStatements() 重现该失败。跟踪预准备语句如何获取其参数列表,并验证示例查询接受 ordinal 1 且执行时不会出现越界异常。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, sql
领域
backend, database
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。