apache/shardingsphere · error · SQLFeatureNotSupportedException

getNClob

Error message

getNClob

What it means

getNClob(int columnIndex) throws SQLFeatureNotSupportedException in the SQL Federation ResultSet (by column index). NCHAR/NVARCHAR/NCLOB nationals-character types are not part of the federation result decoding path, so the accessor is deliberately stubbed out as unsupported rather than returning a value or null.

Source

Thrown at kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/AbstractUnsupportedOperationSQLFederationResultSet.java:155

    
    @Override
    public final boolean rowDeleted() throws SQLException {
        throw new SQLFeatureNotSupportedException("rowDeleted");
    }
    
    @Override
    public final String getCursorName() throws SQLException {
        throw new SQLFeatureNotSupportedException("getCursorName");
    }
    
    @Override
    public final int getHoldability() throws SQLException {
        throw new SQLFeatureNotSupportedException("getHoldability");
    }
    
    @Override
    public final NClob getNClob(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNClob");
    }
    
    @Override
    public final NClob getNClob(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNClob");
    }
    
    @Override
    public final Reader getNCharacterStream(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNCharacterStream");
    }
    
    @Override
    public final Reader getNCharacterStream(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getNCharacterStream");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Use getString(columnIndex) (or getClob + charset handling) for national-character columns; most backends deliver NVARCHAR as String through federation
  2. If a real java.sql.NClob object is required by an API, convert: conn.createNClob() then set the value from getString()
  3. Alter the column type to VARCHAR/CLOB if national-character semantics are not actually needed
  4. Verify the column truly must come from the federated path; querying the shard directly preserves native driver NClob support

Example fix

// before
NClob n = rs.getNClob(1);

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

Strategy: validation

Validate before calling

// National-character columns arrive as String through federation: prefer getString()
// Guard only if you must produce an NClob:
try { rs.getNClob(1); }
catch (final SQLFeatureNotSupportedException e) { /* fall back to getString(1) */ }

Type guard

private String readNationalColumn(final ResultSet rs, final int idx) throws SQLException {
    try { return rs.getNClob(idx).getSubString(1, (int) rs.getNClob(idx).length()); }
    catch (final SQLFeatureNotSupportedException e) { return rs.getString(idx); }
}

Try / catch

NClob clob;
try { clob = rs.getNClob(1); }
catch (final SQLFeatureNotSupportedException e) { clob = toNclob(conn, rs.getString(1)); }

Prevention

When it happens

Trigger: Calling rs.getNClob(1) (any column index) on a federated SELECT that returns national-character data — e.g. reading NTEXT/NVARCHAR columns of a SQL Server or Oracle table through a cross-shard federated query.

Common situations: Reading NCLOB/NTEXT columns of migrated SQL Server/Oracle schemas through ShardingSphere federation; ORM national-character type handlers (Hibernate NClobType) mapped to entity fields; column type changed to NVARCHAR/NCHAR after the app already ran under federation, surfacing the gap only for the affected column.

Related errors


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