apache/shardingsphere · error · SQLFeatureNotSupportedException

updateTimestamp

Error message

updateTimestamp

What it means

AbstractUnsupportedUpdateOperationSQLFederationResultSet defines all row-update methods of ShardingSphere's federation ResultSet as unconditional SQLFeatureNotSupportedException throws; 'updateTimestamp' is the message for the column-index overload. Because the federation engine computes results in memory and offers no writable cursor, in-place java.sql.Timestamp writes through the ResultSet always throw at the call site.

Source

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

    
    @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
    public final void updateTimestamp(final int columnIndex, final Timestamp x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateTimestamp");
    }
    
    @Override
    public final void updateTimestamp(final String columnLabel, final Timestamp x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateTimestamp");
    }
    
    @Override
    public final void updateAsciiStream(final int columnIndex, final InputStream inputStream) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateAsciiStream");
    }
    
    @Override
    public final void updateAsciiStream(final String columnLabel, final InputStream inputStream) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateAsciiStream");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Read with getTimestamp(columnIndex) if needed and write via a PreparedStatement UPDATE using setTimestamp, keyed on the primary key.
  2. Pre-validate rs.getConcurrency() and confine updateXxx usage to CONCUR_UPDATABLE result sets; otherwise use UPDATE statements.
  3. Exclude the statement from the sql_federation rule so the underlying driver's ResultSet semantics are used.

Example fix

// before
rs.updateTimestamp(6, Timestamp.from(Instant.now()));  // SQLFeatureNotSupportedException: updateTimestamp
rs.updateRow();

// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE docs SET modified_at = ? WHERE id = ?")) {
    upd.setTimestamp(1, Timestamp.from(Instant.now()));
    upd.setLong(2, rs.getLong(1));
    upd.executeUpdate();
}
Defensive patterns

Strategy: try-catch

Validate before calling

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

Type guard

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

Try / catch

try {
    rs.updateTimestamp(6, ts);
} catch (final SQLFeatureNotSupportedException ignored) {
    try (PreparedStatement upd = conn.prepareStatement("UPDATE docs SET modified_at = ? WHERE id = ?")) {
        upd.setTimestamp(1, ts);
        upd.setLong(2, rs.getLong(1));
        upd.executeUpdate();
    }
}

Prevention

When it happens

Trigger: Calling ResultSet.updateTimestamp(int columnIndex, Timestamp x) on a federated query ResultSet (sql_federation enabled, e.g. cross-shard join/subquery). Triggered by audit/last-modified stamping code or generic temporal writers that patch the current row in place.

Common situations: Optimistic-locking / audit-stamp code using updateRow migrated onto a ShardingSphere federated datasource; sqlFederation enabled in YAML causing existing statements to federate; framework code that updates timestamps through the cursor on every ResultSet.

Related errors


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