apache/shardingsphere · error · SQLFeatureNotSupportedException

updateDate

Error message

updateDate

What it means

Every updateXxx method on a ShardingSphere SQL federation ResultSet is a final override in AbstractUnsupportedUpdateOperationSQLFederationResultSet that throws SQLFeatureNotSupportedException with the method name as the message — 'updateDate' for the column-index overload. Federation output is a read-only computed view, so writing a java.sql.Date in place through the cursor is unsupported and fails immediately.

Source

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

    
    @Override
    public final void updateNString(final String columnLabel, final String nString) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNString");
    }
    
    @Override
    public final void updateBytes(final int columnIndex, final byte[] x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBytes");
    }
    
    @Override
    public final void updateBytes(final String columnLabel, final byte[] x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateBytes");
    }
    
    @Override
    public final void updateDate(final int columnIndex, final Date x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateDate");
    }
    
    @Override
    public final void updateDate(final String columnLabel, final Date x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateDate");
    }
    
    @Override
    public final void updateTime(final int columnIndex, final Time x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateTime");
    }
    
    @Override
    public final void updateTime(final String columnLabel, final Time x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateTime");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Read with getDate(columnIndex) and persist via a PreparedStatement UPDATE using setDate, keyed on the primary key.
  2. Pre-check rs.getConcurrency(); treat read-only sets as statement-update-only and never call updateRow flows.
  3. Scope the sql_federation rule to exclude this statement so the backend driver's ResultSet is returned.

Example fix

// before
rs.updateDate(3, Date.valueOf("2026-08-14"));  // SQLFeatureNotSupportedException: updateDate
rs.updateRow();

// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE events SET due_date = ? WHERE id = ?")) {
    upd.setDate(1, Date.valueOf("2026-08-14"));
    upd.setLong(2, rs.getLong(1));
    upd.executeUpdate();
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {
    // rs.updateDate(...) unsupported; use UPDATE + setDate
}

Type guard

private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {
    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
}

Try / catch

try {
    rs.updateDate(3, date);
} catch (final SQLFeatureNotSupportedException ignored) {
    try (PreparedStatement upd = conn.prepareStatement("UPDATE events SET due_date = ? WHERE id = ?")) {
        upd.setDate(1, date);
        upd.setLong(2, rs.getLong(1));
        upd.executeUpdate();
    }
}

Prevention

When it happens

Trigger: Calling ResultSet.updateDate(int columnIndex, Date x) on a federation ResultSet (statement executed by the SQL federation engine, e.g. cross-shard join with sql_federation enabled). Seen in scheduling/calendar code or generic date-column editors that patch rows in place.

Common situations: Applications that previously used updatable driver ResultSets for date patches and now run federated queries; sqlFederation enabled during sharding adoption, routing existing statements through federation; reusable row-editing layers that call updateDate on any ResultSet they receive.

Related errors


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