{"record":{"id":"bd78af79c7e39d9a","repo":"apache/shardingsphere","slug":"getbinarystream-bd78af","errorCode":null,"errorMessage":"getBinaryStream","messagePattern":"getBinaryStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":142,"sourceCode":"    \n    @Override\n    public final InputStream getAsciiStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getAsciiStream\");\n    }\n    \n    @Override\n    public final InputStream getUnicodeStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getUnicodeStream\");\n    }\n    \n    @Override\n    public final InputStream getUnicodeStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getUnicodeStream\");\n    }\n    \n    @Override\n    public final InputStream getBinaryStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBinaryStream\");\n    }\n    \n    @Override\n    public final InputStream getBinaryStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getBinaryStream\");\n    }\n    \n    @Override\n    public final SQLWarning getWarnings() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getWarnings\");\n    }\n    \n    @Override\n    public final void clearWarnings() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"clearWarnings\");\n    }\n    \n    @Override","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L124-L160","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nInputStream bin = keys.getBinaryStream(1);\n\n// after\nObject key = keys.getObject(1); // Number (typically Long/BigInteger)","handlingStrategy":"try-catch","validationCode":"int type = keys.getMetaData().getColumnType(1);\nif (type == Types.INTEGER || type == Types.BIGINT) {\n    long id = keys.getLong(1);\n}","typeGuard":"private static boolean isGeneratedKeysRs(ResultSet rs) {\n    return rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    InputStream bin = rs.getBinaryStream(1);\n} catch (SQLFeatureNotSupportedException e) {\n    Object key = rs.getObject(1);\n}","preventionTips":["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."],"tags":["jdbc","shardingsphere","generated-keys","binary","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}