apache/shardingsphere · warning · SQLFeatureNotSupportedException

getAsciiStream

Error message

getAsciiStream

What it means

SQLFeatureNotSupportedException from AbstractUnsupportedDatabaseMetaDataResultSet.getAsciiStream(int): ShardingSphere's DatabaseMetaData result sets deliberately do not implement the deprecated/legacy stream accessors — getAsciiStream, getUnicodeStream, getUnicodeStream(String) — and throw with the method name as the message.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedDatabaseMetaDataResultSet.java:41

import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;

/**
 * Unsupported Database meta data result set.
 */
public abstract class AbstractUnsupportedDatabaseMetaDataResultSet extends AbstractUnsupportedOperationResultSet {
    
    @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. Replace getAsciiStream with getString plus explicit encoding for metadata result sets.
  2. If binary-safe reading is required, use getBytes/getObject instead.
  3. Update legacy code: getAsciiStream on metadata was deprecated since JDBC 2.

Example fix

// before
InputStream in = metaRs.getAsciiStream(1);
// after
String value = metaRs.getString(1);
InputStream in = new ByteArrayInputStream(value.getBytes(StandardCharsets.US_ASCII));
Defensive patterns

Strategy: fallback

Validate before calling

// check capability via instanceof before legacy accessors
if (rs instanceof AbstractUnsupportedDatabaseMetaDataResultSet) useGetStringInstead();

Try / catch

try { rs.getAsciiStream(1); } catch (SQLFeatureNotSupportedException ex) { in = new ByteArrayInputStream(rs.getString(1).getBytes(US_ASCII)); }

Prevention

When it happens

Trigger: Calling rs.getAsciiStream(columnIndex) or rs.getAsciiStream(columnLabel) (or getUnicodeStream variants) on any ResultSet returned by DatabaseMetaData methods of the ShardingSphere driver. Only the metadata result sets are affected; normal query result sets are not backed by this class.

Common situations: Old report/tooling code using deprecated JDBC 1 stream accessors; generic libraries probing every accessor on a result set; copy-pasted legacy data-export routines run against metadata results.

Related errors


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