apache/shardingsphere · error · SQLFeatureNotSupportedException

getCharacterStream

Error message

getCharacterStream

What it means

LocalDataMergedResult.getCharacterStream(columnIndex) always throws SQLFeatureNotSupportedException('getCharacterStream'). Local data merge handles rows assembled inside ShardingSphere (metadata/SHOW results) that contain plain cell values with no underlying Reader source, so character-stream access is deliberately unimplemented.

Source

Thrown at infra/merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/local/LocalDataMergedResult.java:69

    
    @Override
    public Object getValue(final int columnIndex, final Class<?> type) {
        return currentRow.getCell(columnIndex);
    }
    
    @Override
    public Object getCalendarValue(final int columnIndex, final Class<?> type, @SuppressWarnings("UseOfObsoleteDateTimeApi") final Calendar calendar) {
        return currentRow.getCell(columnIndex);
    }
    
    @Override
    public InputStream getInputStream(final int columnIndex, final String type) throws SQLException {
        throw new SQLFeatureNotSupportedException("getInputStream");
    }
    
    @Override
    public Reader getCharacterStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getCharacterStream");
    }
    
    @Override
    public boolean wasNull() {
        return null == currentRow;
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Use rs.getString(i) for character data on locally merged results.
  2. Gate stream access on the statement kind — reserve getCharacterStream for real table queries served by driver-backed merge results.
  3. Catch SQLFeatureNotSupportedException and fall back to getString.

Example fix

// before
Reader r = resultSet.getCharacterStream(1);

// after
String value = resultSet.getString(1);
Defensive patterns

Strategy: fallback

Try / catch

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

Prevention

When it happens

Trigger: Calling rs.getCharacterStream(i) or rs.getNCharacterStream(i) on a ResultSet produced by a locally merged statement (SHOW DATABASES, SHOW SHARDING TABLE RULES, metadata queries) routed through LocalDataMergedResult.

Common situations: Reporting tools that read all text columns as Readers; JDBC helper libraries choosing getCharacterStream for LONGVARCHAR-type columns; code paths shared between driver-backed queries and locally generated result sets.

Related errors


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