apache/shardingsphere · error · SQLFeatureNotSupportedException

getObject with type

Error message

getObject with type

What it means

getObject(int columnIndex, Class<T> type) and its label twin (JDBC 4.1 typed-object accessors) are overridden in AbstractUnsupportedOperationResultSet to throw SQLFeatureNotSupportedException('getObject with type'). The sharding merged ResultSet does not implement the JDBC type-conversion table, so clients must convert fetched values themselves.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java:195

    
    @Override
    public final Ref getRef(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getRef");
    }
    
    @Override
    public final RowId getRowId(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getRowId");
    }
    
    @Override
    public final RowId getRowId(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getRowId");
    }
    
    @Override
    public <T> T getObject(final int columnIndex, final Class<T> type) throws SQLException {
        throw new SQLFeatureNotSupportedException("getObject with type");
    }
    
    @Override
    public <T> T getObject(final String columnLabel, final Class<T> type) throws SQLException {
        throw new SQLFeatureNotSupportedException("getObject with type");
    }
    
    @Override
    public final Object getObject(final String columnLabel, final Map<String, Class<?>> map) throws SQLException {
        throw new SQLFeatureNotSupportedException("getObject with map");
    }
    
    @Override
    public final Object getObject(final int columnIndex, final Map<String, Class<?>> map) throws SQLException {
        throw new SQLFeatureNotSupportedException("getObject with map");
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Use the untyped accessor rs.getObject(col) (or the typed getters getString/getInt/getTimestamp/...) and convert in application code (Integer.valueOf, Timestamp.toLocalDateTime, Map.of...).
  2. Add a JDBC-level shim/extendedResultSetClass if your framework allows customizing ResultSet wrapping, mapping typed calls to untyped ones.
  3. Upgrade ShardingSphere — newer driver versions implement several typed-object conversions; verify against your version's release notes before relying on it.
  4. Check whether your ORM has a dialect/setting that avoids JDBC 4.1 typed accessors (e.g. setting that forces legacy object retrieval).

Example fix

// before
LocalDate d = rs.getObject(2, LocalDate.class); // throws

// after
LocalDate d = rs.getDate(2).toLocalDateTime().toLocalDate();
// or: Object v = rs.getObject(2); then convert explicitly
Defensive patterns

Strategy: fallback

Validate before calling

Object raw = rs.getObject(col); // untyped read always works
// convert explicitly per column type

Type guard

// prefer explicit typed getters instead of the typed-object accessor
LocalDate d = rs.getDate(col) == null ? null : rs.getDate(col).toLocalDateTime().toLocalDate();

Try / catch

try {
    value = rs.getObject(col, targetType);
} catch (SQLFeatureNotSupportedException e) {
    Object raw = rs.getObject(col);
    value = convert(raw, targetType); // your own converter
}

Prevention

When it happens

Trigger: Calling rs.getObject(col, MyClass.class) / rs.getObject("label", MyClass.class) on a sharding ResultSet — extremely common in ORM internals (Hibernate/JPA 6.x heavily uses typed getObject), Spring Data JDBC converters, and jOOQ meta-object access.

Common situations: Upgrading an ORM version that switched from getObject()+cast to typed getObject; frameworks calling getObject(Integer.class), getObject(LocalDate.class), getObject(UUID.class); migration of working code to the sharding URL where the driver now rejects typed reads.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/debc2cf4c19a09ce. Report an issue: GitHub.