apache/shardingsphere · error · SQLFeatureNotSupportedException
updateString
Error message
updateString
What it means
In ShardingSphere, every ResultSet produced by the SQL federation engine extends AbstractUnsupportedUpdateOperationSQLFederationResultSet, whose updateXxx overrides are final and throw SQLFeatureNotSupportedException with the method name ('updateString') as the message. Federation results are read-only computed views, so updating a String column in place via the cursor is always rejected.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:134
@Override
public final void updateDouble(final String columnLabel, final double x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateDouble");
}
@Override
public final void updateBigDecimal(final int columnIndex, final BigDecimal x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBigDecimal");
}
@Override
public final void updateBigDecimal(final String columnLabel, final BigDecimal x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateBigDecimal");
}
@Override
public final void updateString(final int columnIndex, final String x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateString");
}
@Override
public final void updateString(final String columnLabel, final String x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateString");
}
@Override
public final void updateNString(final int columnIndex, final String nString) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNString");
}
@Override
public final void updateNString(final String columnLabel, final String nString) throws SQLException {
throw new SQLFeatureNotSupportedException("updateNString");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use getString(columnIndex) to read and write changes with a PreparedStatement UPDATE keyed on the primary key.
- Before cursor-update code, verify rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE; otherwise use statement-based updates.
- Configure the sql_federation rule so this statement is not federated (scope by SQL pattern/table) and the native ResultSet is returned.
Example fix
// before
rs.updateString(2, "new-name"); // SQLFeatureNotSupportedException: updateString
rs.updateRow();
// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE users SET name = ? WHERE id = ?")) {
upd.setString(1, "new-name");
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
} Defensive patterns
Strategy: try-catch
Validate before calling
if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {
// rs.updateString(...) is unsupported; use UPDATE statements
} Type guard
private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {
return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
} Try / catch
try {
rs.updateString(2, name);
} catch (final SQLFeatureNotSupportedException ignored) {
try (PreparedStatement upd = conn.prepareStatement("UPDATE users SET name = ? WHERE id = ?")) {
upd.setString(1, name);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
}
} Prevention
- Design row editing as read-then-UPDATE, not cursor mutation.
- Assert result-set concurrency in shared table-model utilities before updateXxx.
- Keep admin/edit screens off federated queries or accept their read-only nature.
When it happens
Trigger: Calling ResultSet.updateString(int columnIndex, String x) while iterating a federation ResultSet (query executed by SQL federation, e.g. cross-shard JOIN with sql_federation enabled). Triggered by row editors, admin consoles, or ORM dirty-flush logic that writes back through the cursor.
Common situations: Admin/CRUD screens written against updatable ResultSets later pointed at a ShardingSphere federated datasource; enabling sqlFederation globally and having formerly simple queries federated; generic table-model code that patches cells via updateString.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/9808ec2e32f753ad.
Report an issue: GitHub.