apache/shardingsphere · error · SQLFeatureNotSupportedException
getFetchSize
Error message
getFetchSize
What it means
getFetchSize() is rejected with SQLFeatureNotSupportedException("getFetchSize") by AbstractUnsupportedGeneratedKeysResultSet:187, the base class of ShardingSphere's GeneratedKeysResultSet. The key values live in an in-memory iterator, so there is no fetch size to report and the getter is part of the unsupported fetch-hint surface (setFetchDirection/getFetchDirection/setFetchSize/getFetchSize are all closed together).
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:187
@Override
public final void setFetchDirection(final int direction) throws SQLException {
throw new SQLFeatureNotSupportedException("setFetchDirection");
}
@Override
public final int getFetchDirection() throws SQLException {
throw new SQLFeatureNotSupportedException("getFetchDirection");
}
@Override
public final void setFetchSize(final int rows) throws SQLException {
throw new SQLFeatureNotSupportedException("setFetchSize");
}
@Override
public final int getFetchSize() throws SQLException {
throw new SQLFeatureNotSupportedException("getFetchSize");
}
@Override
public final Blob getBlob(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getBlob");
}
@Override
public final Blob getBlob(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getBlob");
}
@Override
public final Clob getClob(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getClob");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Do not read fetch size from generated-keys result sets; the concept does not apply.
- In generic diagnostics, catch SQLFeatureNotSupportedException and log 'n/a' or fall back to the Statement's value.
- Feature-probe per result-set class in wrapper libraries to avoid repeated exceptions.
- Keep fetch-size accounting on the Statement or query result sets.
Example fix
// before
int size = rs.getFetchSize();
// after
int size;
try {
size = rs.getFetchSize();
} catch (SQLFeatureNotSupportedException e) {
size = -1; // not applicable to generated-keys result set
} Defensive patterns
Strategy: try-catch
Validate before calling
// read fetch size from the Statement instead of the generated-keys ResultSet int size = stmt.getFetchSize();
Type guard
private static boolean supportsFetchHints(ResultSet rs) {
return !rs.getClass().getName().endsWith("GeneratedKeysResultSet");
} Try / catch
int size;
try {
size = rs.getFetchSize();
} catch (SQLFeatureNotSupportedException e) {
size = -1; // n/a
} Prevention
- Point diagnostics at Statement-level fetch size.
- Treat 'unsupported' as a normal probe outcome, not an error.
- Record capability results once per result-set class.
When it happens
Trigger: Calling resultSet.getFetchSize() on the keys ResultSet — e.g. diagnostics that log result-set configuration, or generic iteration wrappers that choose processing strategy based on reported fetch size.
Common situations: Monitoring/audit tooling that records fetch size of every result set; pagination frameworks probing fetch size; behavior change after migrating INSERT-heavy services to ShardingSphere-JDBC where native drivers returned the driver default.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/afd37192064a60da.
Report an issue: GitHub.