Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

JDBC: ResultSet.getObject(int, java.sql.Struct.class) fails for STRUCT column

Aperta
#900 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, sql
Ambito
databases

Direzione di ricerca

The failing call is ResultSet.getObject(int, Class) with java.sql.Struct.class, which throws "Can't convert value to interface java.sql.Struct". Start in the JDBC result set's getObject type-conversion path and see how it handles STRUCT, and check how org.duckdb.DuckDBStruct implements java.sql.Struct. Reproduce with the CREATE TABLE and SELECT from the issue. Done when getObject with Struct.class returns the struct for a STRUCT column and a test covers it.

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

Descrizione

Bug description

For a STRUCT column, DuckDB JDBC reports org.duckdb.DuckDBStruct as the column class through ResultSetMetaData, which extends java.sql.Struct, but ResultSet.getObject(..., Struct.class) fails with a conversion error.

Reproduction

Create a table containing a STRUCT column:

CREATE TABLE test_table (
    struct_col STRUCT(name VARCHAR, age INTEGER) NOT NULL
);

Execute a simple query:

SELECT struct_col FROM test_table;

The ResultSetMetaData reports:

Metadata Value
getColumnName() struct_col
getColumnTypeName() STRUCT("name" VARCHAR, age INTEGER)
getColumnType() 2002 (java.sql.Types.STRUCT)
getColumnClassName() org.duckdb.DuckDBStruct

DuckDBStruct implements java.sql.Struct.

However, attempting to retrieve the value using the standard JDBC typed getter:

Struct value = resultSet.getObject(1, Struct.class);

fails with:

java.sql.SQLException: Can't convert value to interface java.sql.Struct, SQL type: STRUCT

I am using ResultSet.getObject(index, Struct.class) because getStruct() is only exposed through the DuckDB-specific org.duckdb.DuckDBResultSet, rather than the standard java.sql.ResultSet interface.

Environment
  • DuckDB JDBC: 1.5.6.0
  • SQL type: STRUCT
  • Java type reported by metadata: org.duckdb.DuckDBStruct
  • JDBC type: java.sql.Types.STRUCT (2002)
Lingua principale
C++
Stelle
127
Fork
83
Merge medio
13h 55m
PR unite (30g)
30

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di duckdb/duckdb-java

Tutte le issue di duckdb/duckdb-java

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.