apache/shardingsphere · error · SQLFeatureNotSupportedException

getAsciiStream

Error message

getAsciiStream

What it means

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.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:122

    
    @Override
    public final Timestamp getTimestamp(final String columnLabel, final Calendar cal) throws SQLException {
        throw new SQLFeatureNotSupportedException("getTimestamp");
    }
    
    @Override
    public final Array getArray(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getArray");
    }
    
    @Override
    public final Array getArray(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getArray");
    }
    
    @Override
    public final InputStream getAsciiStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getAsciiStream");
    }
    
    @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

View on GitHub (pinned to e952770a21)

Solutions

  1. 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)).
  2. Reserve stream getters for LOB columns on normal query result sets, never for generated keys.
  3. Catch SQLFeatureNotSupportedException and fall back to a string read.

Example fix

// before
InputStream in = rs.getAsciiStream(1);

// after
InputStream in = new java.io.ByteArrayInputStream(
        rs.getString(1).getBytes(java.nio.charset.StandardCharsets.US_ASCII));
Defensive patterns

Strategy: try-catch

Validate before calling

String raw = rs.getString(1); // stream getters unneeded for scalar keys

Type guard

static boolean isShardingGeneratedKeys(ResultSet rs) {
    return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
}

Try / catch

try {
    in = rs.getAsciiStream(1);
} catch (SQLFeatureNotSupportedException e) {
    in = new java.io.ByteArrayInputStream(rs.getString(1).getBytes(java.nio.charset.StandardCharsets.US_ASCII));
}

Prevention

When it happens

Trigger: Calling rs.getAsciiStream(1) on the getGeneratedKeys() result set after an INSERT executed via the ShardingSphere driver.

Common situations: 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:.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/f33b586d5098b64f. Report an issue: GitHub.