apache/shardingsphere · error · SQLFeatureNotSupportedException

createClob

Error message

createClob

What it means

ShardingSphere's JDBC driver does not implement the java.sql.Connection method createClob (creating an empty java.sql.Clob for writing CLOB/character data and binding it via setClob). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. ShardingSphere does not implement client-side LOB factories, so the method always throws. 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:99

    
    @Override
    public void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {
        throw new SQLFeatureNotSupportedException("setNetworkTimeout");
    }
    
    @Override
    public Array createArrayOf(final String typeName, final Object[] elements) throws SQLException {
        throw new SQLFeatureNotSupportedException("createArrayOf");
    }
    
    @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

View on GitHub (pinned to e952770a21)

Solutions

  1. Use PreparedStatement.setString(int, String) or setCharacterStream(int, Reader, long) instead of a Clob object.
  2. Use setClob(int, Reader, long) directly on the PreparedStatement so no Clob factory is needed.
  3. Unwrap the native backend connection to create the Clob only if true CLOB semantics are mandatory, and verify the routed SQL afterwards.
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.createClob(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
    // expected on ShardingSphere connections: fall back to supported API
    log.debug("Driver does not support createClob, using fallback", e);
}

Prevention

When it happens

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

Common situations: Spring's LobHandler/ClobToString converters, Hibernate @Lob String handling in some code paths, DAO layers streaming large text via Clob objects.

Related errors


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