apache/shardingsphere · error · SQLFeatureNotSupportedException
getBinaryStream
Error message
getBinaryStream
What it means
AbstractUnsupportedGeneratedKeysResultSet.getBinaryStream(int columnIndex) always throws SQLFeatureNotSupportedException("getBinaryStream") (line 142). The ShardingSphere generated-keys ResultSet holds only in-memory numeric key values produced by the sharding/facade layer, so there is no binary representation to stream; binary accessors are intentionally unimplemented.
Source
Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:142
@Override
public final InputStream getAsciiStream(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getAsciiStream");
}
@Override
public final InputStream getUnicodeStream(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getUnicodeStream");
}
@Override
public final InputStream getUnicodeStream(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getUnicodeStream");
}
@Override
public final InputStream getBinaryStream(final int columnIndex) throws SQLException {
throw new SQLFeatureNotSupportedException("getBinaryStream");
}
@Override
public final InputStream getBinaryStream(final String columnLabel) throws SQLException {
throw new SQLFeatureNotSupportedException("getBinaryStream");
}
@Override
public final SQLWarning getWarnings() throws SQLException {
throw new SQLFeatureNotSupportedException("getWarnings");
}
@Override
public final void clearWarnings() throws SQLException {
throw new SQLFeatureNotSupportedException("clearWarnings");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use getLong(1)/getObject(1): the single generated-key column is numeric.
- In generic mappers, restrict accessor choice to getObject plus instanceof checks instead of the full stream matrix.
- If binary data is what you actually need, you are querying the wrong result set — run the SELECT that returns the blob column on the statement's normal ResultSet.
- Catch SQLFeatureNotSupportedException in adapter code and retry with getObject as a compatibility shim for third-party libraries.
Example fix
// before InputStream bin = keys.getBinaryStream(1); // after Object key = keys.getObject(1); // Number (typically Long/BigInteger)
Defensive patterns
Strategy: try-catch
Validate before calling
int type = keys.getMetaData().getColumnType(1);
if (type == Types.INTEGER || type == Types.BIGINT) {
long id = keys.getLong(1);
} Type guard
private static boolean isGeneratedKeysRs(ResultSet rs) {
return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
} Try / catch
try {
InputStream bin = rs.getBinaryStream(1);
} catch (SQLFeatureNotSupportedException e) {
Object key = rs.getObject(1);
} Prevention
- In generic mappers, prefer getObject + instanceof over the full accessor matrix.
- Read BLOBs from SELECT result sets, never from getGeneratedKeys().
- Unit-test shared ResultSet utilities against the ShardingSphere driver.
When it happens
Trigger: Calling resultSet.getBinaryStream(1) on the ResultSet returned from Statement.getGeneratedKeys()/PreparedStatement.getGeneratedKeys() when using org.apache.shardingsphere.driver (jdbc module) — typically in generic column readers that pick getBinaryStream for BINARY/VARBINARY types.
Common situations: ORM internals (older Hibernate dialects, iBATIS type handlers) that call getBinaryStream when metadata reports a binary type; code that copies one ResultSet into another (ETL/export tools) using the full accessor matrix; behavior change noticed after adopting sharding-jdbc / ShardingSphere-JDBC.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/bd78af79c7e39d9a.
Report an issue: GitHub.