apache/shardingsphere · error · SQLFeatureNotSupportedException

getHoldability

Error message

getHoldability

What it means

getHoldability() throws SQLFeatureNotSupportedException in the SQL Federation ResultSet. ResultSet holdability (HOLD_CURSORS_OVER_COMMIT vs CLOSE_CURSORS_OVER_COMMIT) governs cursor survival across commits; the federation result is a materialized stream with no transaction-cursor binding, so the attribute is not implemented and the final method always throws.

Source

Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedOperationSQLFederationResultSet.java:150

    
    @Override
    public final boolean rowUpdated() throws SQLException {
        throw new SQLFeatureNotSupportedException("rowUpdated");
    }
    
    @Override
    public final boolean rowDeleted() throws SQLException {
        throw new SQLFeatureNotSupportedException("rowDeleted");
    }
    
    @Override
    public final String getCursorName() throws SQLException {
        throw new SQLFeatureNotSupportedException("getCursorName");
    }
    
    @Override
    public final int getHoldability() throws SQLException {
        throw new SQLFeatureNotSupportedException("getHoldability");
    }
    
    @Override
    public final NClob getNClob(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNClob");
    }
    
    @Override
    public final NClob getNClob(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNClob");
    }
    
    @Override
    public final Reader getNCharacterStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNCharacterStream");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Query holdability at Connection/DatabaseMetaData level (conn.getHoldability(), dbmd.getResultSetHoldability()) instead of per-ResultSet
  2. Make inspection wrappers defensive: wrap getHoldability() in try/catch (SQLFeatureNotSupportedException) and report 'unsupported'
  3. Exclude such probing utilities from federation datasources or short-circuit them by product name

Example fix

// before
report("holdability", rs.getHoldability());

// after
try {
    report("holdability", rs.getHoldability());
} catch (final SQLFeatureNotSupportedException ignore) {
    report("holdability", "unsupported");
}
Defensive patterns

Strategy: try-catch

Validate before calling

int holdability;
try { holdability = rs.getHoldability(); }
catch (final SQLFeatureNotSupportedException e) { holdability = conn.getHoldability(); /* query at connection level */ }

Type guard

private int safeHoldability(final ResultSet rs, final Connection conn) throws SQLException {
    try { return rs.getHoldability(); }
    catch (final SQLFeatureNotSupportedException e) { return conn.getHoldability(); }
}

Try / catch

try {
    report("holdability", rs.getHoldability());
} catch (final SQLFeatureNotSupportedException e) {
    report("holdability", conn.getHoldability());
}

Prevention

When it happens

Trigger: Calling rs.getHoldability() on a federated ResultSet — commonly inside generic JDBC inspection utilities, monitoring wrappers, or frameworks that print full ResultSet capability reports for every result set they process.

Common situations: Connection-pool monitoring or SQL-logging wrappers (p6spy-style) that probe holdability per ResultSet; test harnesses asserting JDBC capability matrices; the error appears only for federation-classified statements, so it can surface intermittently after enabling sql-federation, making it look data-dependent.

Related errors


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