{"record":{"id":"1d2f3ea5e45b9484","repo":"apache/shardingsphere","slug":"getcursorname","errorCode":null,"errorMessage":"getCursorName","messagePattern":"getCursorName","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java","lineNumber":145,"sourceCode":"    \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\n    public final boolean rowDeleted() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"rowDeleted\");\n    }\n    \n    @Override\n    public final String getCursorName() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getCursorName\");\n    }\n    \n    @Override\n    public final int getHoldability() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getHoldability\");\n    }\n    \n    @Override\n    public final NClob getNClob(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNClob\");\n    }\n    \n    @Override\n    public final NClob getNClob(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNClob\");\n    }\n    \n    @Override","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java#L127-L163","documentation":"getCursorName() is final in AbstractUnsupportedOperationResultSet and throws SQLFeatureNotSupportedException. Named cursors only exist for positioned UPDATE/DELETE CURRENT OF statements, which the sharding driver cannot support because rows come from multiple merged physical ResultSets with no shared cursor name.","triggerScenarios":"Calling ResultSet.getCursorName() on a sharding ResultSet — typically legacy code building 'UPDATE ... WHERE CURRENT OF cursor' statements or generic JDBC introspection utilities that dump all ResultSet metadata.","commonSituations":"Code migrated from Oracle/DB2/PostgreSQL that uses positioned updates; ORM or query-tool code that calls getCursorName during capability probing; 'UPDATE ... WHERE CURRENT OF' patterns applied to a sharded schema.","solutions":["Replace positioned updates with keyed UPDATE/DELETE statements using the primary key.","Remove or guard getCursorName calls in introspection/probing code (catch SQLFeatureNotSupportedException or skip when the driver is ShardingSphere).","Perform CURRENT OF workflows on a connection from the physical datasource."],"exampleFix":"// before\nString cursor = rs.getCursorName(); // throws\nstmt.executeUpdate(\"UPDATE t SET c=1 WHERE CURRENT OF \" + cursor);\n\n// after\nstmt.executeUpdate(\"UPDATE t SET c=1 WHERE id=\" + rs.getLong(\"id\"));","handlingStrategy":"try-catch","validationCode":"// introspection tools: probe driver identity before calling\nDatabaseMetaData md = conn.getMetaData();\nboolean isSharding = md.getURL().startsWith(\"jdbc:shardingsphere:\");\nif (!isSharding) { String c = rs.getCursorName(); }","typeGuard":null,"tryCatchPattern":"try {\n    cursorName = rs.getCursorName();\n} catch (SQLFeatureNotSupportedException e) {\n    cursorName = null; // positioned CURRENT OF unsupported; use keyed DML\n}","preventionTips":["Replace WHERE CURRENT OF with WHERE pk = ? everywhere.","Make generic JDBC introspection tolerant of SQLFeatureNotSupportedException.","Do not select ROWID/cursor pseudo-columns through the sharding layer."],"tags":["jdbc","resultset","cursor","shardingsphere","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}