apache/shardingsphere · error · SQLFeatureNotSupportedException
createBlob
Error message
createBlob
What it means
ShardingSphere's JDBC driver does not implement the java.sql.Connection method createBlob (creating an empty java.sql.Blob for writing BLOB data and binding it via setBlob). 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:94
@Override
public int getNetworkTimeout() throws SQLException {
throw new SQLFeatureNotSupportedException("getNetworkTimeout");
}
@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");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use PreparedStatement.setBytes(int, byte[]) or setBinaryStream(int, InputStream, long) instead of a Blob object - both are routed as ordinary parameters.
- Use setBlob(int, InputStream, long) directly on the PreparedStatement, which avoids needing a created Blob.
- Only if byte-for-byte LOB semantics are required, unwrap the backend driver connection and create the Blob on it, verifying with sql-show that the parameter reaches the database intact.
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.createBlob(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
// expected on ShardingSphere connections: fall back to supported API
log.debug("Driver does not support createBlob, using fallback", e);
} Prevention
- Bind binary data with setBytes or setBinaryStream instead of createBlob + setBlob.
- Check the JDBC URL before calling optional JDBC 4 methods: connections starting with jdbc:shardingsphere: never support the lob/network-timeout/client-info/callable APIs.
- Catch java.sql.SQLFeatureNotSupportedException (parent of ShardingSphere's UnsupportedSQLOperationException) around optional driver-capability calls so the application degrades gracefully.
When it happens
Trigger: Calling Connection.createBlob() on a ShardingSphere connection.
Common situations: ORMs or DAO layers that stream binary data via Blob objects (Hibernate @Lob byte[] handling in some dialects, framework LobHandler code); applications ported from drivers where createBlob is available.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/ddb66ea988b549a0.
Report an issue: GitHub.