apache/shardingsphere · error · SQLFeatureNotSupportedException

updateTime

Error message

updateTime

What it means

ShardingSphere's federation ResultSets make the JDBC updatable-cursor contract explicitly unavailable: AbstractUnsupportedUpdateOperationSQLFederationResultSet overrides every updateXxx method to throw SQLFeatureNotSupportedException, with 'updateTime' as the message for the column-index overload of the time updater. Federated rows are in-memory computed results, so writing a java.sql.Time in place through the cursor always fails.

Source

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

    
    @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
    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

View on GitHub (pinned to e952770a21)

Solutions

  1. Read with getTime(columnIndex) and write through a PreparedStatement UPDATE using setTime, keyed on the primary key.
  2. Check rs.getConcurrency() before entering update-cursor code and use statement-based updates for read-only sets.
  3. Configure the sql_federation rule so the statement bypasses federation and gets the driver's native ResultSet.

Example fix

// before
rs.updateTime(4, Time.valueOf("12:30:00"));  // SQLFeatureNotSupportedException: updateTime
rs.updateRow();

// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE shifts SET start_time = ? WHERE id = ?")) {
    upd.setTime(1, Time.valueOf("12:30:00"));
    upd.setLong(2, rs.getLong(1));
    upd.executeUpdate();
}
Defensive patterns

Strategy: try-catch

Validate before calling

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

Type guard

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

Try / catch

try {
    rs.updateTime(4, time);
} catch (final SQLFeatureNotSupportedException ignored) {
    try (PreparedStatement upd = conn.prepareStatement("UPDATE shifts SET start_time = ? WHERE id = ?")) {
        upd.setTime(1, time);
        upd.setLong(2, rs.getLong(1));
        upd.executeUpdate();
    }
}

Prevention

When it happens

Trigger: Calling ResultSet.updateTime(int columnIndex, Time x) on the ResultSet of a federated statement (sql_federation enabled, e.g. cross-shard join). Encountered in timesheet/scheduling code or generic temporal column writers that use cursor updates.

Common situations: Code ported from driver-native updatable ResultSets to a ShardingSphere federated datasource; sqlFederation enabled globally so existing statements federate; shared JDBC utility layers that patch TIME columns via updateTime regardless of the ResultSet implementation.

Related errors


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