apache/shardingsphere · error · SQLFeatureNotSupportedException
getCursorName
Error message
getCursorName
What it means
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.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.java:145
@Override
public final boolean rowInserted() throws SQLException {
throw new SQLFeatureNotSupportedException("rowInserted");
}
@Override
public final boolean rowUpdated() throws SQLException {
throw new SQLFeatureNotSupportedException("rowUpdated");
}
@Override
public final boolean rowDeleted() throws SQLException {
throw new SQLFeatureNotSupportedException("rowDeleted");
}
@Override
public final String getCursorName() throws SQLException {
throw new SQLFeatureNotSupportedException("getCursorName");
}
@Override
public final int getHoldability() throws SQLException {
throw new SQLFeatureNotSupportedException("getHoldability");
}
@Override
public final NClob getNClob(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getNClob");
}
@Override
public final NClob getNClob(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getNClob");
}
@OverrideView on GitHub (pinned to e952770a21)
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.
Example fix
// before
String cursor = rs.getCursorName(); // throws
stmt.executeUpdate("UPDATE t SET c=1 WHERE CURRENT OF " + cursor);
// after
stmt.executeUpdate("UPDATE t SET c=1 WHERE id=" + rs.getLong("id")); Defensive patterns
Strategy: try-catch
Validate before calling
// introspection tools: probe driver identity before calling
DatabaseMetaData md = conn.getMetaData();
boolean isSharding = md.getURL().startsWith("jdbc:shardingsphere:");
if (!isSharding) { String c = rs.getCursorName(); } Try / catch
try {
cursorName = rs.getCursorName();
} catch (SQLFeatureNotSupportedException e) {
cursorName = null; // positioned CURRENT OF unsupported; use keyed DML
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/1d2f3ea5e45b9484.
Report an issue: GitHub.