{"record":{"id":"ceb13184cd3e91d9","repo":"apache/shardingsphere","slug":"updatencharacterstream","errorCode":null,"errorMessage":"updateNCharacterStream","messagePattern":"updateNCharacterStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":284,"sourceCode":"    \n    @Override\n    public final void updateCharacterStream(final String columnLabel, final Reader reader, final int length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \n    @Override\n    public final void updateCharacterStream(final int columnIndex, final Reader x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \n    @Override\n    public final void updateCharacterStream(final String columnLabel, final Reader reader, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \n    @Override\n    public final void updateNCharacterStream(final int columnIndex, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNCharacterStream\");\n    }\n    \n    @Override\n    public final void updateNCharacterStream(final String columnLabel, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNCharacterStream\");\n    }\n    \n    @Override\n    public final void updateNCharacterStream(final int columnIndex, final Reader x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNCharacterStream\");\n    }\n    \n    @Override\n    public final void updateNCharacterStream(final String columnLabel, final Reader x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNCharacterStream\");\n    }\n    \n    @Override","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L266-L302","documentation":"The federation ResultSet throws SQLFeatureNotSupportedException(\"updateNCharacterStream\") from updateNCharacterStream(int, Reader). This is the JDBC 4.0 national-character-set variant of positioned updates; as with all update methods in AbstractUnsupportedUpdateOperationSQLFederationResultSet, it is a final stub that always throws because SQL federation results are read-only merged snapshots with no write-back to shards.","triggerScenarios":"Calling rs.updateNCharacterStream(columnIndex, reader) (no length) on a federation result set — e.g. updating an NCHAR/NVARCHAR/NCLOB-typed column of a federated query row — before rs.updateRow().","commonSituations":"Applications using updateNCharacterStream for Unicode text columns (common on databases with national character types); ShardingSphere deployments with SQL federation enabled; ORMs or utilities that prefer N* JDBC methods for internationalized text.","solutions":["Write N-character data with an explicit UPDATE statement and setNCharacterStream.","Avoid federation routing for this query by simplifying the SQL or adjusting sharding/federation configuration.","Refactor update flows to statement-based writes throughout the persistence layer."],"exampleFix":"// before\nrs.updateNCharacterStream(3, nReader); // throws\nrs.updateRow();\n\n// after\nPreparedStatement ps = conn.prepareStatement(\"UPDATE t_msg SET content = ? WHERE id = ?\");\nps.setNCharacterStream(1, nReader);\nps.setLong(2, id);\nps.executeUpdate();","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE\n        || rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet) {\n    // use UPDATE + setNCharacterStream instead\n}","typeGuard":"boolean isFederationResultSet(ResultSet rs) {\n    return rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet;\n}","tryCatchPattern":"try {\n    rs.updateNCharacterStream(col, reader);\n} catch (SQLFeatureNotSupportedException e) {\n    // fall back to PreparedStatement UPDATE with setNCharacterStream\n}","preventionTips":["Use setNCharacterStream on statements for Unicode column writes.","Never rely on positioned updates behind the federation engine.","Verify N-character update flows with integration tests under ShardingSphere."],"tags":["jdbc","sql-federation","resultset","nchar","readonly"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}