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
- Drop the Map argument and call rs.getObject("column") / rs.getObject(i), then cast the returned Object yourself.
- If the column really is a structured/Oracle object type, read it through the native driver connection, not the ShardingSphere connection.
- 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
- Never pass a type map unless the column is a real structured type on a driver that supports it.
- Strip Oracle-specific type-map plumbing when porting to MySQL/PostgreSQL sharding.
- Guard vendor-specific JDBC extensions behind a dialect layer.
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.