{"record":{"id":"1a7d1111a28518ab","repo":"apache/shardingsphere","slug":"updatenclob","errorCode":null,"errorMessage":"updateNClob","messagePattern":"updateNClob","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java","lineNumber":394,"sourceCode":"    \n    @Override\n    public final void updateClob(final String columnLabel, final Reader reader) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateClob\");\n    }\n    \n    @Override\n    public final void updateClob(final int columnIndex, final Reader reader, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateClob\");\n    }\n    \n    @Override\n    public final void updateClob(final String columnLabel, final Reader reader, final long length) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateClob\");\n    }\n    \n    @Override\n    public final void updateNClob(final int columnIndex, final NClob nClob) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNClob\");\n    }\n    \n    @Override\n    public final void updateNClob(final String columnLabel, final NClob nClob) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNClob\");\n    }\n    \n    @Override\n    public final void updateNClob(final int columnIndex, final Reader reader) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNClob\");\n    }\n    \n    @Override\n    public final void updateNClob(final String columnLabel, final Reader reader) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"updateNClob\");\n    }\n    \n    @Override","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedUpdateOperationSQLFederationResultSet.java#L376-L412","documentation":"The SQL federation engine in ShardingSphere returns a read-only, forward-only ResultSet whose updater layer (AbstractUnsupportedUpdateOperationSQLFederationResultSet) deliberately rejects every JDBC row-update method. Calling updateNClob(int, NClob) throws SQLFeatureNotSupportedException because federation queries are computed in-memory from merged results and cannot be written back to the underlying shards. This mirrors how the JDBC driver reports an optional feature that is not implemented.","triggerScenarios":"Executing a federated query (cross-shard JOIN, subquery, or UNION routed through the SQL federation engine) and then calling rs.updateNClob(columnIndex, nClob) on the returned ResultSet, e.g. before rs.updateRow().","commonSituations":"ORM frameworks (Hibernate, MyBatis with updatable result maps, Spring Data JDBC) that auto-detect updatable ResultSets; code ported from a native MySQL/PostgreSQL driver where NClob updates worked; generic JDBC tooling that calls updateNClob when getConcurrency() is misreported.","solutions":["Do not use ResultSet updater methods on federation results; issue a separate UPDATE statement against the target table instead.","Rewrite the query so it is not routed to the federation engine (e.g. make it a single-shard query) if you must use updatable ResultSets.","Configure or exclude the SQL federation feature (sql_federation: false / remove SQLFederationRule) for statements where updater methods are required.","Catch SQLFeatureNotSupportedException and fall back to a plain UPDATE via PreparedStatement in generic JDBC utility code."],"exampleFix":"// before\nResultSet rs = stmt.executeQuery(\"SELECT t.*, u.name FROM t JOIN u ON ... federated\");\nrs.next();\nrs.updateNClob(1, nclob); // SQLFeatureNotSupportedException\nrs.updateRow();\n\n// after\nResultSet rs = stmt.executeQuery(\"SELECT ... federated\");\nrs.next();\nString sql = nclob == null ? \"UPDATE t SET clob_col = NULL WHERE id = ?\" : \"UPDATE t SET clob_col = ? WHERE id = ?\";\ntry (PreparedStatement ps = conn.prepareStatement(sql)) { ps.setNClob(1, nclob); ps.setLong(2, id); ps.executeUpdate(); }","handlingStrategy":"try-catch","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) { throw new IllegalStateException(\"ResultSet is not updatable; use UPDATE statement\"); }","typeGuard":null,"tryCatchPattern":"try { rs.updateNClob(1, nclob); } catch (final SQLFeatureNotSupportedException ex) { /* fall back to PreparedStatement UPDATE */ }","preventionTips":["Never call ResultSet updater methods on SQL federation results; treat them as read-only.","Check rs.getConcurrency() and rs.getType() before using updater APIs.","Write updates as explicit UPDATE statements via PreparedStatement."],"tags":["jdbc","resultset","sql-federation","unsupported-operation","nclob"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}