apache/shardingsphere · error · SQLFeatureNotSupportedException

getSQLXML

Error message

getSQLXML

What it means

getSQLXML(int columnIndex) (and its String overload on line 224) closes out AbstractUnsupportedGeneratedKeysResultSet with an unconditional SQLFeatureNotSupportedException("getSQLXML") throw at line 222. ShardingSphere's generated-keys ResultSet holds synthesized numeric key values, so the JDBC 4 SQLXML accessor — already optional in the JDBC spec — is declared unsupported.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedGeneratedKeysResultSet.java:222

    
    @Override
    public final Clob getClob(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getClob");
    }
    
    @Override
    public final URL getURL(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getURL");
    }
    
    @Override
    public final URL getURL(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getURL");
    }
    
    @Override
    public final SQLXML getSQLXML(final int columnIndex) throws SQLException {
        throw new SQLFeatureNotSupportedException("getSQLXML");
    }
    
    @Override
    public final SQLXML getSQLXML(final String columnLabel) throws SQLException {
        throw new SQLFeatureNotSupportedException("getSQLXML");
    }
}

View on GitHub (pinned to e952770a21)

Solutions

  1. Read the key with getLong(1)/getObject(1); generated keys are never XML.
  2. Scope SQLXML type handling to SELECT result sets only.
  3. In reflective walkers, catch SQLFeatureNotSupportedException and mark the accessor unavailable.
  4. If XML data is needed, fetch it with a later SELECT using the generated key.

Example fix

// before
SQLXML xml = keys.getSQLXML(1);

// after
long id = keys.getLong(1);
Defensive patterns

Strategy: try-catch

Validate before calling

int type = keys.getMetaData().getColumnType(1);
if (type == Types.INTEGER || type == Types.BIGINT) { long id = keys.getLong(1); } // never SQLXML

Type guard

private static boolean isGeneratedKeysRs(ResultSet rs) {
    return rs.getClass().getName().endsWith("GeneratedKeysResultSet");
}

Try / catch

try {
    SQLXML xml = rs.getSQLXML(1);
} catch (SQLFeatureNotSupportedException e) {
    Object key = rs.getObject(1);
}

Prevention

When it happens

Trigger: Calling resultSet.getSQLXML(1) or getSQLXML(columnLabel) on the ResultSet obtained from Statement.getGeneratedKeys()/PreparedStatement.getGeneratedKeys() in ShardingSphere-JDBC — e.g. an ORM XML type handler applied generically, or a full-accessor walker.

Common situations: Modern ORM type handlers (XML-typed fields) run against every result set; reflection-based mappers enumerating all getters; applications moved onto sharding-jdbc for sharding/encryption where the same INSERT previously ran on a driver accepting the call or throwing a different error.

Related errors


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