apache/shardingsphere · error · SQLFeatureNotSupportedException
getClob
Error message
getClob
What it means
getClob(int columnIndex) always throws SQLFeatureNotSupportedException("getClob") in AbstractUnsupportedGeneratedKeysResultSet:202, the parent of ShardingSphere's GeneratedKeysResultSet. Generated keys are held as an in-memory iterator of numeric values, so there is no CLOB to return and the accessor is explicitly unsupported rather than returning null.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:202
@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");
}
@Override
public final Clob getClob(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getClob");
}
@Override
public final URL getURL(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getURL");
}
@Override
public final URL getURL(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getURL");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use keys.getString(1)/keys.getLong(1) instead.
- Gate CLOB handling to SELECT result sets; never run it on generated-keys output.
- If character payload is needed, SELECT it afterward using the generated key.
- In adapters, catch SQLFeatureNotSupportedException and retry with getString(1).
Example fix
// before Clob c = keys.getClob(1); // after String id = keys.getString(1);
Defensive patterns
Strategy: try-catch
Validate before calling
int type = keys.getMetaData().getColumnType(1);
if (type != Types.CLOB) { String id = keys.getString(1); } Type guard
private static boolean isGeneratedKeysRs(ResultSet rs) {
return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
} Try / catch
try {
Clob c = rs.getClob(1);
} catch (SQLFeatureNotSupportedException e) {
String v = rs.getString(1);
} Prevention
- Scope CLOB type handlers to text columns of query result sets.
- Read generated keys with getString/getLong.
- Don't reuse generic row-serialization code on key result sets.
When it happens
Trigger: Calling resultSet.getClob(1) on the keys ResultSet from getGeneratedKeys() — often from generic mappers whose metadata inspection of the key column steers them into CLOB handling, or from code that reads all columns as LOBs first.
Common situations: Legacy CLOB-based text handling applied to every result set; data-export pipelines; apps previously on native drivers where getClob on generated keys threw a friendlier error or returned null — after adopting ShardingSphere-JDBC the SQLFeatureNotSupportedException surfaces at the same call site.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/b0fecb912a77cde8.
Report an issue: GitHub.