{"record":{"id":"3b0a2fa7be0bb138","repo":"apache/shardingsphere","slug":"getcharacterstream-3b0a2f","errorCode":null,"errorMessage":"getCharacterStream","messagePattern":"getCharacterStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":162,"sourceCode":"    \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\n    public final Reader getCharacterStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getCharacterStream\");\n    }\n    \n    @Override\n    public final Reader getCharacterStream(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getCharacterStream\");\n    }\n    \n    @Override\n    public final void setFetchDirection(final int direction) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setFetchDirection\");\n    }\n    \n    @Override\n    public final int getFetchDirection() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getFetchDirection\");\n    }\n    \n    @Override","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L144-L180","documentation":"The int-overload getCharacterStream(int columnIndex) throws SQLFeatureNotSupportedException(\"getCharacterStream\") unconditionally in AbstractUnsupportedGeneratedKeysResultSet:162, so it fails on the ResultSet ShardingSphere returns from getGeneratedKeys(). The generated-keys result set contains a single numeric column assembled in memory; Reader-based column access is not part of its contract.","triggerScenarios":"Calling resultSet.getCharacterStream(1) on the keys ResultSet — typical of generic row mappers (Hibernate legacy type handlers, Jackson/CSV serializers) that choose getCharacterStream for CHAR/VARCHAR/LONGVARCHAR metadata types.","commonSituations":"Generic ORM serialization of 'whatever result set is open' after an INSERT; utility code that dumps any ResultSet to JSON/CSV; apps whose native driver returned a Reader over the key's string form and only broke once ShardingSphere-JDBC took over statement routing.","solutions":["Read the key with getLong(1)/getBigDecimal(1)/getObject(1); convert to String in Java if character data is needed.","In generic mappers, use getObject(1) and format via toString() rather than branching into Reader accessors.","Do not run row-serialization logic against getGeneratedKeys() output; serialize the entity you already have in memory.","For third-party mappers you cannot patch, catch SQLFeatureNotSupportedException and fall back to getString(1)."],"exampleFix":"// before\nReader r = keys.getCharacterStream(1);\n\n// after\nString id = keys.getString(1); // or keys.getLong(1)","handlingStrategy":"try-catch","validationCode":"int type = keys.getMetaData().getColumnType(1);\nif (type == Types.INTEGER || type == Types.BIGINT) {\n    long id = keys.getLong(1); // never use Reader accessors here\n}","typeGuard":"private static boolean isGeneratedKeysRs(ResultSet rs) {\n    return rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    Reader r = rs.getCharacterStream(1);\n} catch (SQLFeatureNotSupportedException e) {\n    String v = rs.getString(1);\n}","preventionTips":["Serialize entities from your own objects after INSERT; don't dump key result sets.","Default generic mappers to getObject().","Reserve Reader accessors for verified text columns in query result sets."],"tags":["jdbc","shardingsphere","generated-keys","reader","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}