apache/shardingsphere · error · SQLFeatureNotSupportedException

createSQLXML

Error message

createSQLXML

What it means

ShardingSphere's JDBC driver does not implement the java.sql.Connection method createSQLXML (creating an empty java.sql.SQLXML object for writing XML data and binding it via setSQLXML). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. ShardingSphere does not implement SQLXML plumbing, so the factory method always throws on its connections. The exception is thrown the moment the method is invoked on any connection produced by the ShardingSphere Driver.

Source

Thrown at jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java:109

    
    @Override
    public final Blob createBlob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createBlob");
    }
    
    @Override
    public Clob createClob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createClob");
    }
    
    @Override
    public final NClob createNClob() throws SQLException {
        throw new SQLFeatureNotSupportedException("createNClob");
    }
    
    @Override
    public final SQLXML createSQLXML() throws SQLException {
        throw new SQLFeatureNotSupportedException("createSQLXML");
    }
    
    @Override
    public final Struct createStruct(final String typeName, final Object[] attributes) throws SQLException {
        throw new SQLFeatureNotSupportedException("createStruct");
    }
    
    @Override
    public final Properties getClientInfo() throws SQLException {
        throw new SQLFeatureNotSupportedException("getClientInfo");
    }
    
    @Override
    public final String getClientInfo(final String name) throws SQLException {
        throw new SQLFeatureNotSupportedException("getClientInfo name");
    }
    
    @Override

View on GitHub (pinned to e952770a21)

Solutions

  1. Send XML as a String or stream: setString / setCharacterStream with the backend column typed as XML (PostgreSQL xml, SQL Server XML) usually works through ShardingSphere's normal parameter pipeline.
  2. For SQL Server specifically, use setBinaryStream with UTF-8 bytes for XML parameters, or wrap with SQLXMLDataModel only on a native connection.
  3. Route XML-heavy operations through a separate non-sharded DataSource.
Defensive patterns

Strategy: try-catch

Validate before calling

boolean supportsOp = false;
try {
    connection.getMetaData(); // connection is alive
    // JDBC has no capability flag for individual methods; probe once per JVM:
    supportsOp = probeSupport(connection); // reflective/one-time guarded call
} catch (final SQLException ignored) {
}
// Simpler and recommended: capability-check by driver URL
boolean isShardingSphere = url.startsWith("jdbc:shardingsphere:");
if (isShardingSphere) {
    // skip the unsupported call, use the alternative API path
}

Try / catch

try {
    connection.createSQLXML(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
    // expected on ShardingSphere connections: fall back to supported API
    log.debug("Driver does not support createSQLXML, using fallback", e);
}

Prevention

When it happens

Trigger: Calling Connection.createSQLXML() on a ShardingSphere connection.

Common situations: SQL Server / DB2 / PostgreSQL applications storing XML columns via SQLXML objects; ORM XML mapping types that call createSQLXML during flush.

Related errors


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