{"record":{"id":"f33b586d5098b64f","repo":"apache/shardingsphere","slug":"getasciistream-f33b58","errorCode":null,"errorMessage":"getAsciiStream","messagePattern":"getAsciiStream","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java","lineNumber":122,"sourceCode":"    \n    @Override\n    public final Timestamp getTimestamp(final String columnLabel, final Calendar cal) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTimestamp\");\n    }\n    \n    @Override\n    public final Array getArray(final int columnIndex) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getArray\");\n    }\n    \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","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java#L104-L140","documentation":"getAsciiStream(int columnIndex) is final and always throws in AbstractUnsupportedGeneratedKeysResultSet. The generated-keys result set exposes key values only through getString/getBytes/getObject-style getters; streaming ASCII reads are not implemented because keys are small scalar values, not streamable LOBs.","triggerScenarios":"Calling rs.getAsciiStream(1) on the getGeneratedKeys() result set after an INSERT executed via the ShardingSphere driver.","commonSituations":"Generic row readers that use stream getters for character columns (a pattern for CLOB/long text in vendor drivers) applied uniformly to all result sets, including generated keys. Code that worked under MySQL/PostgreSQL drivers and fails under jdbc:shardingsphere:.","solutions":["Use rs.getString(1) (or getBytes(1)/getObject(1)) and, if a stream is required, wrap it: new ByteArrayInputStream(rs.getString(1).getBytes(StandardCharsets.US_ASCII)).","Reserve stream getters for LOB columns on normal query result sets, never for generated keys.","Catch SQLFeatureNotSupportedException and fall back to a string read."],"exampleFix":"// before\nInputStream in = rs.getAsciiStream(1);\n\n// after\nInputStream in = new java.io.ByteArrayInputStream(\n        rs.getString(1).getBytes(java.nio.charset.StandardCharsets.US_ASCII));","handlingStrategy":"try-catch","validationCode":"String raw = rs.getString(1); // stream getters unneeded for scalar keys","typeGuard":"static boolean isShardingGeneratedKeys(ResultSet rs) {\n    return rs.getClass().getName().endsWith(\"GeneratedKeysResultSet\");\n}","tryCatchPattern":"try {\n    in = rs.getAsciiStream(1);\n} catch (SQLFeatureNotSupportedException e) {\n    in = new java.io.ByteArrayInputStream(rs.getString(1).getBytes(java.nio.charset.StandardCharsets.US_ASCII));\n}","preventionTips":["Use stream getters only for LOB columns on normal query result sets.","Wrap string reads in ByteArrayInputStream when streaming APIs are mandatory.","Include the ShardingSphere driver in tests for any LOB-oriented row reader."],"tags":["jdbc","shardingsphere","generated-keys","resultset","sql-feature-not-supported","stream"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}