apache/shardingsphere · error · SQLFeatureNotSupportedException

getNClob

Error message

getNClob

What it means

getNClob(int columnIndex) is final in AbstractUnsupportedOperationResultSet and throws SQLFeatureNotSupportedException. The sharding driver does not materialize NCHAR/NVARCHAR/NCLOB columns as java.sql.NClob objects in its merged ResultSet, so the N-specific accessor is disabled by design.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationResultSet.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. Fetch the value as String or Clob: getString(columnIndex) or getClob(columnIndex), and convert as needed; for large data use getCharacterStream and wrap it.
  2. If an NClob instance is required, create one via connection.createNClob() and copy the characters.
  3. Adjust row-mapper type switches to map NCLOB to String/Clob handling when running under ShardingSphere.

Example fix

// before
NClob nclob = rs.getNClob(2); // throws

// after
String value = rs.getString(2);
// or stream: Reader r = rs.getNCharacterStream-like via rs.getCharacterStream(2)
Defensive patterns

Strategy: type-guard

Validate before calling

// check the column really is NCLOB, then use String/Clob path anyway
int type = rs.getMetaData().getColumnType(col);
if (type == Types.NCLOB || type == Types.NVARCHAR) { value = rs.getString(col); }

Type guard

boolean nValueViaString(ResultSetMetaData md, int col) throws SQLException {
    int t = md.getColumnType(col);
    return t == Types.NCLOB || t == Types.NVARCHAR || t == Types.NCHAR;
    // always true: use getString/getCharacterStream under this driver
}

Try / catch

try {
    nclob = rs.getNClob(col);
} catch (SQLFeatureNotSupportedException e) {
    nclob = null;
    value = rs.getString(col);
}

Prevention

When it happens

Trigger: Calling ResultSet.getNClob(columnIndex) on a ResultSet from ShardingSphereDataSource — typically generic row-mapper code that switches on java.sql.Types.NCLOB, or copied vendor sample code for national-character columns.

Common situations: Row mappers that branch on JDBC column type to pick getNClob; migration from MySQL/Oracle drivers that return NClob for national character columns; ORM dialect code that prefers NClob accessors.

Related errors


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