apache/shardingsphere · error · SQLFeatureNotSupportedException
getNetworkTimeout
Error message
getNetworkTimeout
What it means
ShardingSphere's JDBC driver does not implement the java.sql.Connection method getNetworkTimeout (reading the JDBC 4 network/socket timeout (milliseconds) configured on the connection). The abstract base class AbstractUnsupportedOperationConnection, which ShardingSphereConnection extends, overrides it as final and unconditionally throws SQLFeatureNotSupportedException. ShardingSphere does not expose a single network timeout across its multiple backend connections, so the getter 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:79
@Override
public final void abort(final Executor executor) throws SQLException {
throw new SQLFeatureNotSupportedException("abort");
}
@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");
}
@OverrideView on GitHub (pinned to e952770a21)
Solutions
- Set timeouts where they are honored: pass socketTimeout/connectTimeout properties in each backend JDBC URL inside the ShardingSphere datasource configuration.
- Use Statement.setQueryTimeout() (supported by ShardingSphere) instead of network timeouts for query deadlines.
- If a framework requires getNetworkTimeout(), catch SQLFeatureNotSupportedException and fall back to a configured default value.
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.getNetworkTimeout(/* args */);
} catch (final SQLFeatureNotSupportedException e) {
// expected on ShardingSphere connections: fall back to supported API
log.debug("Driver does not support getNetworkTimeout, using fallback", e);
} Prevention
- Set socketTimeout/connectTimeout in each storage unit's JDBC URL rather than reading/setting network timeouts through the logical connection.
- 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.getNetworkTimeout() on a ShardingSphere connection.
Common situations: Connection pools and frameworks that read network timeouts to enforce query deadlines; HikariCP-style initialization paths that inspect JDBC 4 capabilities; monitoring tools probing driver feature levels.
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/8e0dd73f83a73e9a.
Report an issue: GitHub.