{"record":{"id":"471db477def152c6","repo":"apache/shardingsphere","slug":"getunicodestream-471db4","errorCode":null,"errorMessage":"getUnicodeStream","messagePattern":"getUnicodeStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":132,"sourceCode":"    \n    @Override\n    public final Array getArray(final String columnLabel) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getArray\");\n    }\n    \n    @Override\n    public final InputStream getAsciiStream(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getAsciiStream\");\n    }\n    \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","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L114-L150","documentation":"GeneratedKeysResultSet, the ResultSet ShardingSphere's driver returns from getGeneratedKeys(), inherits getUnicodeStream(int) from AbstractUnsupportedGeneratedKeysResultSet as an unconditional throw of SQLFeatureNotSupportedException(\"getUnicodeStream\"). getUnicodeStream is itself a deprecated JDBC 1.0 method, and since generated keys are synthesized scalar values there is no unicode character stream to return.","triggerScenarios":"Calling resultSet.getUnicodeStream(int columnIndex) on the ResultSet returned by Statement.getGeneratedKeys() or PreparedStatement.getGeneratedKeys() in the ShardingSphere driver (line 132 covers the columnIndex overload).","commonSituations":"Very old JDBC code or code translated from JDK 1.1-era samples still using getUnicodeStream; automated result-set-to-POJO mappers that enumerate every accessor; apps moved onto ShardingSphere-JDBC for sharding where the native driver previously returned a (possibly empty) stream.","solutions":["Replace with getLong(1)/getObject(1) — getUnicodeStream has been deprecated since JDBC 2.0 and even on native drivers is discouraged.","If character data is genuinely expected, you are using the wrong result set: generated keys only ever contain the key column.","Catch SQLFeatureNotSupportedException around legacy library calls and re-fetch the key with a typed getter or a follow-up query.","Remove dead getUnicodeStream branches from generic mappers; no current driver guarantees them."],"exampleFix":"// before\nInputStream raw = keys.getUnicodeStream(1);\n\n// after\nlong id = keys.getLong(1);","handlingStrategy":"try-catch","validationCode":"if (keys.getMetaData().getColumnCount() == 1) {\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 in = rs.getUnicodeStream(1);\n} catch (SQLFeatureNotSupportedException e) {\n    Object v = rs.getObject(1); // safe fallback\n}","preventionTips":["Delete getUnicodeStream usages — deprecated since JDBC 2.0.","Centralize generated-key reads in one utility that only uses getLong/getObject.","Static-analysis rule: forbid getUnicodeStream in the codebase."],"tags":["jdbc","shardingsphere","generated-keys","deprecated-api","unsupported-operation"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}