apache/shardingsphere · error · SQLFeatureNotSupportedException

getObject with map

Error message

getObject with map

What it means

ShardingSphere's driver ResultSet does not implement getObject(String columnLabel, Map<String, Class<?>> map). It throws SQLFeatureNotSupportedException('getObject with map'). The map-based overload is used for structured/DISTINCT object types (SQL:1999 structured types) and is rarely implemented by sharding or pooling drivers; only the single-argument getObject is supported.

Source

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

    
    @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. Drop the Map argument and call rs.getObject("column") / rs.getObject(i), then cast the returned Object yourself.
  2. If the column really is a structured/Oracle object type, read it through the native driver connection, not the ShardingSphere connection.
  3. Wrap access in a helper that detects SQLFeatureNotSupportedException and falls back to the 1-arg overload for scalar columns.

Example fix

// before
Object v = rs.getObject("order_type", typeMap);

// after
Object v = rs.getObject("order_type");
Defensive patterns

Strategy: try-catch

Validate before calling

if (typeMap != null && !typeMap.isEmpty() && conn.getMetaData().getURL().startsWith("jdbc:shardingsphere:")) {
    // map-based getObject is unsupported; use the 1-arg overload
}

Type guard

private static Object getObjectSafe(ResultSet rs, String label, Map<String, Class<?>> map) throws SQLException {
    try {
        return rs.getObject(label, map);
    } catch (SQLFeatureNotSupportedException e) {
        return rs.getObject(label);
    }
}

Try / catch

try {
    v = rs.getObject(label, typeMap);
} catch (SQLFeatureNotSupportedException e) {
    v = rs.getObject(label);
}

Prevention

When it happens

Trigger: Calling rs.getObject("column", typeMap) or rs.getObject(index, typeMap) with a non-empty java.util.Map of SQL type names to Java classes — typically code ported from Oracle that reads STRUCT/REF/DISTINCT typed columns through a connection type map.

Common situations: Porting Oracle JDBC code that uses connection type maps for object types to a sharded MySQL/PostgreSQL setup via jdbc:shardingsphere:; legacy DAO layers that always pass a type map even for scalar columns; tools/beans that introspect ResultSet methods and invoke the Map overload generically.

Related errors


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