apache / apache/arrow-java

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

Aperta
#121 15 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
94
Fork
152
Merge medio
3g 16h
PR unite (30g)
11

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Iniziate dal punto di ingresso getParameter(int param) mostrato nell’issue e riproducete il problema tramite handleSqlStatements() utilizzando l’URL JDBC di Flight SQL, la query preparata e setInt(1, 12345). Tracciate il modo in cui lo statement preparato ottiene l’elenco dei parametri e verificate che la query di esempio accetti l’ordinale 1 e venga eseguita senza l’eccezione di indice fuori intervallo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java, sql
Ambito
backend, database
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.