apache/shardingsphere · error · SQLFeatureNotSupportedException

updateSQLXML

Error message

updateSQLXML

What it means

updateSQLXML(int, SQLXML) throws SQLFeatureNotSupportedException on ShardingSphere federation ResultSets. SQLXML updates require driver support for DOM/stream XML binding against an updatable row; the federation layer provides neither, and its updater base class marks the method unsupported.

Source

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

    
    @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
    public final void updateSQLXML(final int columnIndex, final SQLXML xmlObject) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateSQLXML");
    }
    
    @Override
    public final void updateSQLXML(final String columnLabel, final SQLXML xmlObject) throws SQLException {
        throw new SQLFeatureNotSupportedException("updateSQLXML");
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Serialize the XML and write it with a PreparedStatement UPDATE (setSQLXML if supported by the underlying driver, else setString with XML text).
  2. Keep federation result sets read-only in application design.
  3. Re-route the statement away from federation when cursor updates are needed.
  4. Add try-catch fallback in generic XML persistence layers.

Example fix

// before
SQLXML xml = conn.createSQLXML();
xml.setString(docXml);
rs.updateSQLXML(2, xml);
rs.updateRow();

// after
try (PreparedStatement ps = conn.prepareStatement("UPDATE doc SET payload = ? WHERE id = ?")) {
    ps.setString(1, docXml);
    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.updateSQLXML(1, xml); } catch (final SQLFeatureNotSupportedException ex) { /* serialize and UPDATE */ }

Prevention

When it happens

Trigger: Calling rs.updateSQLXML(columnIndex, xmlObject) where xmlObject came from conn.createSQLXML(), on a federation-routed SELECT result, then rs.updateRow().

Common situations: Applications writing XML documents to XML-typed columns (SQL Server, Oracle, PostgreSQL) through ShardingSphere with sql_federation on; ETL jobs using SQLXML to avoid string serialization.

Related errors


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