apache/shardingsphere · error · SQLFeatureNotSupportedException
relative
Error message
relative
What it means
relative(int rows) — moving the cursor a relative number of rows — is not supported by the SQL Federation ResultSet and always throws SQLFeatureNotSupportedException. The class whitelists only forward streaming methods; every relative/absolute scroll operation is rejected.
Source
Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedOperationSQLFederationResultSet.java:85
@Override
public boolean first() throws SQLException {
throw new SQLFeatureNotSupportedException("first");
}
@Override
public boolean last() throws SQLException {
throw new SQLFeatureNotSupportedException("last");
}
@Override
public boolean absolute(final int row) throws SQLException {
throw new SQLFeatureNotSupportedException("absolute");
}
@Override
public boolean relative(final int rows) throws SQLException {
throw new SQLFeatureNotSupportedException("relative");
}
@Override
public int getRow() throws SQLException {
throw new SQLFeatureNotSupportedException("getRow");
}
@Override
public final void insertRow() throws SQLException {
throw new SQLFeatureNotSupportedException("insertRow");
}
@Override
public final void updateRow() throws SQLException {
throw new SQLFeatureNotSupportedException("updateRow");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Replace skip loops with SQL-level OFFSET/LIMIT windows
- Emulate forward skips with a counted next() loop (for (int i=0;i<n && rs.next();i++))
- Materialize the result set client-side if bidirectional relative movement is a hard requirement
Example fix
// before
rs.relative(10); // skip 10 rows
// after
for (int i = 0; i < 10 && rs.next(); i++) { /* skip */ } Defensive patterns
Strategy: validation
Validate before calling
if (rs.getType() == ResultSet.TYPE_FORWARD_ONLY) {
// relative(n) unsupported: emulate with a counted next() loop
} Type guard
private boolean supportsRelative(final ResultSet rs) throws SQLException {
return rs.getType() != ResultSet.TYPE_FORWARD_ONLY;
} Try / catch
try {
rs.relative(skip);
} catch (final SQLFeatureNotSupportedException e) {
for (int i = 0; i < skip && rs.next(); i++) { /* skip forward */ }
} Prevention
- Avoid relative() in batch/skip loops; use OFFSET windows
- Treat any negative relative() as a design smell on federated reads
- Encapsulate skipping in one utility that knows the cursor type
When it happens
Trigger: Calling rs.relative(n) or rs.relative(-n) on a federated ResultSet, e.g. skip-ahead loops (relative(5)) or step-back loops written for scrollable cursors, executed against ShardingSphere with sql-federation enabled.
Common situations: Batch-processing code that skips N rows at a time; ported desktop-report tooling; ORM plugins that use relative() for windowed reads. Appears when such code runs against a federation-routed statement (cross-shard join,联邦查询) rather than a native driver connection.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/cfe53dba7dd7112f.
Report an issue: GitHub.