apache/shardingsphere · error · SQLFeatureNotSupportedException

Get Character stream

Error message

Get Character stream

What it means

MemoryMergedResult.getCharacterStream(columnIndex) throws SQLFeatureNotSupportedException('Get Character stream'). When results are materialized for in-memory merging, cells are plain objects with no character-stream backend, so Reader access is intentionally unsupported.

Source

Thrown at infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/memory/MemoryMergedResult.java:98

        return result;
    }
    
    @Override
    public final Object getCalendarValue(final int columnIndex, final Class<?> type, @SuppressWarnings("UseOfObsoleteDateTimeApi") final Calendar calendar) {
        // TODO implement with calendar
        Object result = currentResultSetRow.getCell(columnIndex);
        wasNull = null == result;
        return result;
    }
    
    @Override
    public final InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
        throw new SQLFeatureNotSupportedException(String.format("Get input stream from `%s`", type));
    }
    
    @Override
    public Reader getCharacterStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("Get Character stream");
    }
    
    @Override
    public final boolean wasNull() {
        return wasNull;
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Use rs.getString(i) for text columns on memory-merged results.
  2. Split LOB retrieval from the aggregated query into a plain SELECT by primary key that bypasses memory merge.
  3. Catch SQLFeatureNotSupportedException and fall back to getString.

Example fix

// before
Reader text = resultSet.getCharacterStream(2);

// after
String text = resultSet.getString(2);
Defensive patterns

Strategy: fallback

Try / catch

try (Reader r = rs.getCharacterStream(i)) { ... } catch (SQLFeatureNotSupportedException e) { String text = rs.getString(i); ... }

Prevention

When it happens

Trigger: Calling rs.getCharacterStream(i) on a memory-merged result set — SELECTs with GROUP BY / aggregates / cross-shard ORDER BY / LIMIT that ShardingSphere merged in memory.

Common situations: Text-heavy columns (CLOB/TEXT) read via Reader in shared data-access layers; queries that became memory-merged after adding aggregation or ordering; frameworks auto-selecting character-stream reads for java.sql.Types.LONGVARCHAR columns.

Related errors


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