apache/shardingsphere · error · SQLFeatureNotSupportedException

getArray

Error message

getArray

What it means

getArray(int columnIndex) is final and always throws in AbstractUnsupportedGeneratedKeysResultSet. Generated keys are single scalar Comparable values per row; there is no array-valued column, so java.sql.Array extraction is unimplemented by design.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:112

    
    @Override
    public final Timestamp getTimestamp(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getTimestamp");
    }
    
    @Override
    public final Timestamp getTimestamp(final int columnIndex, final Calendar cal) throws SQLException {
        throw new SQLFeatureNotSupportedException("getTimestamp");
    }
    
    @Override
    public final Timestamp getTimestamp(final String columnLabel, final Calendar cal) throws SQLException {
        throw new SQLFeatureNotSupportedException("getTimestamp");
    }
    
    @Override
    public final Array getArray(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getArray");
    }
    
    @Override
    public final Array getArray(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getArray");
    }
    
    @Override
    public final InputStream getAsciiStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getAsciiStream");
    }
    
    @Override
    public final InputStream getAsciiStream(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getAsciiStream");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Use rs.getObject(1) or rs.getString(1); a generated key is never an SQL array.
  2. Remove array-handling branches from generated-key processing code.
  3. Catch SQLFeatureNotSupportedException and skip/ignore the column as a defensive measure.

Example fix

// before
Array a = rs.getArray(1);

// after
Object key = rs.getObject(1); // generated keys are scalar
Defensive patterns

Strategy: try-catch

Validate before calling

Object key = rs.getObject(1); // generated keys are scalar; never arrays

Type guard

static boolean isShardingGeneratedKeys(ResultSet rs) {
    return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
}

Try / catch

try {
    arr = rs.getArray(1);
} catch (SQLFeatureNotSupportedException e) {
    Object key = rs.getObject(1); // handle scalar directly
}

Prevention

When it happens

Trigger: Calling rs.getArray(1) on the getGeneratedKeys() result set after an INSERT through the ShardingSphere driver.

Common situations: Generic reflection-based row mappers that try typed getters including getArray for every column type. Code copied from vendor-driver projects where getArray returned null or an empty Array instead of throwing.

Related errors


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