apache/shardingsphere · error · SQLFeatureNotSupportedException

updateArray

Error message

updateArray

What it means

updateArray(int, Array) on a ShardingSphere federation ResultSet throws SQLFeatureNotSupportedException. Federation results are computed and merged in memory; there is no updatable row and no Array-typed column write path, so the updater base class rejects all Array updates by design.

Source

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

    
    @Override
    public final void updateNClob(final String columnLabel, final Reader reader) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNClob");
    }
    
    @Override
    public final void updateNClob(final int columnIndex, final Reader reader, final long length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNClob");
    }
    
    @Override
    public final void updateNClob(final String columnLabel, final Reader reader, final long length) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateNClob");
    }
    
    @Override
    public final void updateArray(final int columnIndex, final Array x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateArray");
    }
    
    @Override
    public final void updateArray(final String columnLabel, final Array x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateArray");
    }
    
    @Override
    public final void updateRowId(final int columnIndex, final RowId x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateRowId");
    }
    
    @Override
    public final void updateRowId(final String columnLabel, final RowId x) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateRowId");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Write array values with a dedicated UPDATE (setArray, or the dialect's array literal syntax) instead of the ResultSet updater.
  2. Remove the statement from federation routing (rewrite the SQL or disable sql_federation) if updatable cursors are required.
  3. Prefer storing arrays as JSON and updating via setString if cross-database portability matters.
  4. In shared JDBC code, catch SQLFeatureNotSupportedException and fall back to UPDATE.

Example fix

// before
Array arr = conn.createArrayOf("int", new Integer[]{1,2});
rs.updateArray(3, arr);
rs.updateRow();

// after
Array arr = conn.createArrayOf("int", new Integer[]{1,2});
try (PreparedStatement ps = conn.prepareStatement("UPDATE t SET tags = ? WHERE id = ?")) {
    ps.setArray(1, arr);
    ps.setLong(2, id);
    ps.executeUpdate();
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (rs.getConcurrency() != ResultSet.CONCUR_UPDATABLE) { throw new IllegalStateException("ResultSet is not updatable; use UPDATE statement"); }

Try / catch

try { rs.updateArray(1, arr); } catch (final SQLFeatureNotSupportedException ex) { /* ps.setArray fallback */ }

Prevention

When it happens

Trigger: Calling rs.updateArray(columnIndex, array) (e.g. java.sql.Array created via Connection.createArrayOf) on the ResultSet of a federated SELECT, followed by rs.updateRow().

Common situations: Applications using PostgreSQL-style array columns through ShardingSphere proxy/JDBC with sql_federation enabled; generic schema-browsing or admin tools that attempt in-place edits of array columns.

Related errors


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