{"record":{"id":"9c21f268673d89b0","repo":"apache/shardingsphere","slug":"updatecharacterstream","errorCode":null,"errorMessage":"updateCharacterStream","messagePattern":"updateCharacterStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":254,"sourceCode":"    \n    @Override\n    public final void updateBinaryStream(final String columnLabel, final InputStream x, final int length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBinaryStream\");\n    }\n    \n    @Override\n    public final void updateBinaryStream(final int columnIndex, final InputStream x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBinaryStream\");\n    }\n    \n    @Override\n    public final void updateBinaryStream(final String columnLabel, final InputStream x, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateBinaryStream\");\n    }\n    \n    @Override\n    public final void updateCharacterStream(final int columnIndex, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \n    @Override\n    public final void updateCharacterStream(final String columnLabel, final Reader x) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \n    @Override\n    public final void updateCharacterStream(final int columnIndex, final Reader x, final int length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateCharacterStream\");\n    }\n    \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","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L236-L272","documentation":"The federation ResultSet throws SQLFeatureNotSupportedException(\"updateCharacterStream\") from the two-argument updateCharacterStream(int, Reader). Character-stream positioned updates are part of the JDBC row-update API, which SQL federation deliberately does not support: its result sets are merged, read-only views over shard query results, and every update method in AbstractUnsupportedUpdateOperationSQLFederationResultSet is a final throwing stub.","triggerScenarios":"Calling rs.updateCharacterStream(columnIndex, reader) (no length) on a federation result set — typically writing CLOB/TEXT content — followed by rs.updateRow().","commonSituations":"Applications updating TEXT columns via Reader streams with positioned updates; sql_federation enabled in ShardingSphere config so JOINs/subqueries return federation result sets; code ported from direct database connections whose drivers permitted updatable result sets.","solutions":["Use a PreparedStatement UPDATE with setCharacterStream instead.","Rewrite the query or adjust sharding/federation rules so it does not go through federation.","Remove all ResultSet.update* usage from the codebase in favor of statement-based writes."],"exampleFix":"// before\nrs.updateCharacterStream(1, reader); // throws\nrs.updateRow();\n\n// after\nPreparedStatement ps = conn.prepareStatement(\"UPDATE t_article SET body = ? WHERE id = ?\");\nps.setCharacterStream(1, reader);\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 + setCharacterStream instead\n}","typeGuard":"boolean isFederationResultSet(ResultSet rs) {\n    return rs instanceof org.apache.shardingsphere.sqlfederation.resultset.SQLFederationResultSet;\n}","tryCatchPattern":"try {\n    rs.updateCharacterStream(col, reader);\n} catch (SQLFeatureNotSupportedException e) {\n    // fall back to PreparedStatement UPDATE with setCharacterStream\n}","preventionTips":["Write TEXT/CLOB content via UPDATE statements with setCharacterStream.","Never assume updatable cursors behind a federation or proxy layer.","Add regression tests for text-update flows under ShardingSphere."],"tags":["jdbc","sql-federation","resultset","clob","readonly"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}