apache/shardingsphere · error · SQLFeatureNotSupportedException
createNClob
Error message
createNClob
What it means
ShardingSphere's JDBC driver does not implement the java.sql.Connection method createNClob (creating an empty java.sql.NClob for national-character (NCHAR/NVARCHAR/NCLOB) data). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. ShardingSphere does not implement client-side LOB factories, and NCLOB support is not part of its feature matrix, 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:104
@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
public final Properties getClientInfo() throws SQLException {
throw new SQLFeatureNotSupportedException("getClientInfo");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Use setNString(int, String) or setNCharacterStream(int, Reader, long) on the PreparedStatement instead of an NClob object.
- If the backend column is a plain CLOB/VARCHAR, use setString/setClob(Reader) and drop national-character typing.
- For genuine NCLOB columns on Oracle/SQL Server backends, unwrap the native connection to create the NClob and verify the routed statement 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.createNClob(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
// expected on ShardingSphere connections: fall back to supported API
log.debug("Driver does not support createNClob, using fallback", e);
} Prevention
- Use setNString/setNCharacterStream instead of NClob objects for national-character columns.
- 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.createNClob() on a ShardingSphere connection.
Common situations: Code written against drivers with full JDBC 4 national-character support (Oracle, SQL Server); ORM nationalized-character mappings (Hibernate @Nationalized); frameworks that probe NClob capability.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/b26a7e7921a26aab.
Report an issue: GitHub.