{"record":{"id":"d67dd4662018960a","repo":"apache/shardingsphere","slug":"movetoinsertrow-d67dd4","errorCode":null,"errorMessage":"moveToInsertRow","messagePattern":"moveToInsertRow","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedOperationSQLFederationResultSet.java","lineNumber":120,"sourceCode":"    \n    @Override\n    public final void deleteRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"deleteRow\");\n    }\n    \n    @Override\n    public final void refreshRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"refreshRow\");\n    }\n    \n    @Override\n    public final void cancelRowUpdates() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"cancelRowUpdates\");\n    }\n    \n    @Override\n    public final void moveToInsertRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"moveToInsertRow\");\n    }\n    \n    @Override\n    public final void moveToCurrentRow() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"moveToCurrentRow\");\n    }\n    \n    @Override\n    public final boolean rowInserted() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"rowInserted\");\n    }\n    \n    @Override\n    public final boolean rowUpdated() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"rowUpdated\");\n    }\n    \n    @Override","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedOperationSQLFederationResultSet.java#L102-L138","documentation":"moveToInsertRow() throws SQLFeatureNotSupportedException in the SQL Federation ResultSet. The JDBC insert-row is a special cursor position only meaningful for updatable result sets; since federation results are read-only forward streams, the abstract base class rejects entering insert mode.","triggerScenarios":"Calling rs.moveToInsertRow() as the first step of the updatable-ResultSet insert pattern (moveToInsertRow -> updateXXX -> insertRow) on a federated query ResultSet.","commonSituations":"DB grid tools adding a new row; DAOs using insert-row mode to avoid writing INSERT SQL; code that worked against a native driver's updatable ResultSet and later ran on a ShardingSphere federation connection (e.g. after enabling federation for cross-shard queries).","solutions":["Use PreparedStatement INSERT statements for new rows instead of the insert-row cursor API","If a framework component issues moveToInsertRow, configure it to generate SQL inserts or point it at a non-federation datasource","Review whether the query triggering federation can avoid the federation path so native driver capabilities are preserved"],"exampleFix":"// before\nrs.moveToInsertRow();\nrs.updateString(1, \"v\");\nrs.insertRow();\n\n// after\ntry (PreparedStatement ps = conn.prepareStatement(\"INSERT INTO t(c) VALUES (?)\")) {\n    ps.setString(1, \"v\");\n    ps.executeUpdate();\n}","handlingStrategy":"validation","validationCode":"if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) {\n    // moveToInsertRow() unsupported: use INSERT statements\n}","typeGuard":"private boolean isUpdatable(final ResultSet rs) throws SQLException {\n    return rs.getConcurrency() == ResultSet.CONCUR_UPDATABLE;\n}","tryCatchPattern":"try {\n    rs.moveToInsertRow();\n} catch (final SQLFeatureNotSupportedException e) {\n    insertViaStatement(conn, rowValues);\n}","preventionTips":["Never enter insert-row mode without checking CONCUR_UPDATABLE","Use PreparedStatement INSERT for new rows","Configure editors to generate SQL, not cursor mutations"],"tags":["jdbc","resultset","sql-federation","updatable-cursor","insert","shardingsphere"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}