apache/shardingsphere · error · SQLFeatureNotSupportedException
updateNString
Error message
updateNString
What it means
The federation ResultSet returned by ShardingSphere's SQL federation engine overrides every updateXxx method in AbstractUnsupportedUpdateOperationSQLFederationResultSet to throw SQLFeatureNotSupportedException, message 'updateNString' for the national-character-string updater (column-index overload). NString in-place writes are unsupported because the federated result is a read-only, in-memory computed view, not an updatable database cursor.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java:144
@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");
}
@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");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Read with getNString(columnIndex) and perform writes through a PreparedStatement UPDATE using setNString, keyed on the primary key.
- Check rs.getConcurrency() before update-cursor code; for read-only concurrency use statement-based writes only.
- Adjust the sql_federation rule so the statement bypasses federation and returns the backend driver's ResultSet.
Example fix
// before
rs.updateNString(5, "こんにちは"); // SQLFeatureNotSupportedException: updateNString
// after
try (PreparedStatement upd = conn.prepareStatement("UPDATE messages SET body = ? WHERE id = ?")) {
upd.setNString(1, "こんにちは");
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
} Defensive patterns
Strategy: try-catch
Validate before calling
if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {
// rs.updateNString(...) unsupported; use UPDATE + setNString
} Type guard
private static boolean supportsRowUpdates(final ResultSet rs) throws SQLException {
return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;
} Try / catch
try {
rs.updateNString(5, text);
} catch (final SQLFeatureNotSupportedException ignored) {
try (PreparedStatement upd = conn.prepareStatement("UPDATE messages SET body = ? WHERE id = ?")) {
upd.setNString(1, text);
upd.setLong(2, rs.getLong(1));
upd.executeUpdate();
}
} Prevention
- Use setNString on a keyed UPDATE for Unicode column writes.
- Verify result-set concurrency before using N-variant update methods.
- Track which statements are federated when i18n columns are involved.
When it happens
Trigger: Calling ResultSet.updateNString(int columnIndex, String nString) on a federation ResultSet (statement executed via sql_federation, e.g. cross-shard join). Encountered in i18n-heavy applications or generic column writers that handle NVARCHAR/NCHAR via the N-variants of JDBC methods.
Common situations: Code that uniformly uses updateNString for Unicode-safe writes running against a newly federated ShardingSphere datasource; framework migration where NVARCHAR editing code paths receive federation result sets; sqlFederation enabled for queries previously served by the underlying driver's updatable cursor.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/5c6d7b87c09fc616.
Report an issue: GitHub.