apache/shardingsphere · error · SQLFeatureNotSupportedException

getInputStream

Error message

getInputStream

What it means

LocalDataMergedResult merges locally produced rows (e.g. results for SHOW/metadata-style statements built inside ShardingSphere). Its getInputStream(columnIndex, type) has no meaningful implementation because local rows hold plain cell values, not streamable LOB sources, so it always throws SQLFeatureNotSupportedException('getInputStream').

Source

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

            currentRow = rows.next();
            return true;
        }
        return false;
    }
    
    @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) or rs.getObject(i) for locally merged results instead of stream access.
  2. Branch on statement type: only use stream access for SELECTs against real tables that go through driver-backed results.
  3. Catch SQLFeatureNotSupportedException and fall back to getObject for these result sets.

Example fix

// before
InputStream in = resultSet.getBinaryStream(2);

// after
Object cell = resultSet.getObject(2);
byte[] bytes = cell instanceof byte[] ? (byte[]) cell : String.valueOf(cell).getBytes(StandardCharsets.UTF_8);
Defensive patterns

Strategy: fallback

Try / catch

try (InputStream in = rs.getBinaryStream(i)) { ... } catch (SQLFeatureNotSupportedException e) { byte[] b = rs.getBytes(i); ... }

Prevention

When it happens

Trigger: Application or framework code calling rs.getBinaryStream(i) (which routes to getInputStream with a binary type) on a ResultSet whose merge result is LocalDataMergedResult — typically results of SHOW statements, metadata queries, or other locally generated result sets.

Common situations: Generic ORM/streaming helpers that unconditionally use getBinaryStream for BLOB-ish columns; the same code path working against driver-backed merge results but failing for locally merged SHOW results; tests replaying SHOW queries through the proxy with stream-based readers.

Related errors


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