apache/shardingsphere · error · SQLFeatureNotSupportedException
updateFloat
Error message
updateFloat
What it means
SQL federation result sets in ShardingSphere are read-only by construction: AbstractUnsupportedUpdateOperationSQLFederationResultSet overrides every JDBC row-update method to throw SQLFeatureNotSupportedException, and these overrides are final so subclasses cannot enable them. The message 'updateFloat' identifies the rejected method. Federated queries are materialized by the federation engine, so there is no backing updatable cursor to write through.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:104
@Override
public final void updateInt(final String columnLabel, final int x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateInt");
}
@Override
public final void updateLong(final int columnIndex, final long x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateLong");
}
@Override
public final void updateLong(final String columnLabel, final long x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateLong");
}
@Override
public final void updateFloat(final int columnIndex, final float x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateFloat");
}
@Override
public final void updateFloat(final String columnLabel, final float x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateFloat");
}
@Override
public final void updateDouble(final int columnIndex, final double x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateDouble");
}
@Override
public final void updateDouble(final String columnLabel, final double x) throws SQLException {
throw new SQLFeatureNotSupportedException("updateDouble");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use getFloat(columnIndex) to read and issue an explicit UPDATE statement for writes; never call updateFloat on a federation ResultSet.
- Check rs.getConcurrency() (or DatabaseMetaData.supportsResultSetConcurrency) before entering update-cursor code and fall back to UPDATE statements for CONCUR_READ_ONLY sets.
- Narrow the sql_federation rule so this particular statement is not federated, letting the underlying driver return its native (possibly updatable) ResultSet.
Example fix
// before
rs.next();
rs.updateFloat(2, 1.5f); // SQLFeatureNotSupportedException: updateFloat
rs.updateRow();
// after
float current = rs.getFloat(2);
try (PreparedStatement upd = conn.prepareStatement("UPDATE metrics SET score = ? WHERE id = ?")) {
upd.setFloat(1, 1.5f);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
} Defensive patterns
Strategy: try-catch
Validate before calling
boolean updatable = rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
if (!updatable) {
// use UPDATE statements instead of rs.updateFloat(...)
} Type guard
private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {
return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
} Try / catch
try {
rs.updateFloat(2, score);
} catch (final SQLFeatureNotSupportedException ignored) {
try (PreparedStatement upd = conn.prepareStatement("UPDATE metrics SET score = ? WHERE id = ?")) {
upd.setFloat(1, score);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
}
} Prevention
- Route all writes through PreparedStatement/Statement APIs, never the ResultSet cursor, when federation may be active.
- Verify DatabaseMetaData.supportsResultSetConcurrency before adopting updatable-cursor code.
- Document which queries are federated so teams know those ResultSets are read-only.
When it happens
Trigger: Calling ResultSet.updateFloat(int columnIndex, float x) on the ResultSet of a federation-executed query (sql_federation applies, e.g. cross-shard join, UNION, or federated subquery). Triggered by row-editing utilities, grid components, or ORMs that use updatable-cursor APIs.
Common situations: Reusing GUI/reporting/grid code that edits rows via updateXxx against a ShardingSphere datasource with sql_federation turned on; migrating an application from raw MySQL/PostgreSQL updatable ResultSets to ShardingSphere federation; version upgrades where a statement newly qualifies for federation execution.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/7e24e163edc7b2d2.
Report an issue: GitHub.