apache/shardingsphere · error · SQLFeatureNotSupportedException
setNetworkTimeout
Error message
setNetworkTimeout
What it means
ShardingSphere's JDBC driver does not implement the java.sql.Connection method setNetworkTimeout (setting the JDBC 4 network/socket timeout on the connection). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. Applying one network timeout to all underlying backend connections is not implemented, so the mutator 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:84
@Override
public final Map<String, Class<?>> getTypeMap() throws SQLException {
throw new SQLFeatureNotSupportedException("getTypeMap");
}
@Override
public final void setTypeMap(final Map<String, Class<?>> map) throws SQLException {
throw new SQLFeatureNotSupportedException("setTypeMap");
}
@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");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Configure socketTimeout/connectTimeout per backend datasource in the ShardingSphere YAML (jdbcUrl of each storage unit) instead of calling setNetworkTimeout.
- Use Statement.setQueryTimeout() for per-statement deadlines, which ShardingSphere supports.
- Catch SQLFeatureNotSupportedException around optional timeout setup so applications still run when the driver lacks the feature.
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.setNetworkTimeout(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
// expected on ShardingSphere connections: fall back to supported API
log.debug("Driver does not support setNetworkTimeout, using fallback", e);
} Prevention
- Use Statement.setQueryTimeout for deadlines; configure socket timeouts per backend datasource in the YAML.
- 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.setNetworkTimeout(executor, milliseconds) on a ShardingSphere connection.
Common situations: Connection pools applying network timeouts after checkout; application code migrating from a plain driver where setNetworkTimeout worked; spring.jdbc or framework bootstrap that configures socket timeouts via JDBC 4 APIs.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/f136ba3fd99ee0a4.
Report an issue: GitHub.