{"record":{"id":"8e0dd73f83a73e9a","repo":"apache/shardingsphere","slug":"getnetworktimeout","errorCode":null,"errorMessage":"getNetworkTimeout","messagePattern":"getNetworkTimeout","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java","lineNumber":79,"sourceCode":"    \n    @Override\n    public final void abort(final Executor executor) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"abort\");\n    }\n    \n    @Override\n    public final Map<String, Class<?>> getTypeMap() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getTypeMap\");\n    }\n    \n    @Override\n    public final void setTypeMap(final Map<String, Class<?>> map) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setTypeMap\");\n    }\n    \n    @Override\n    public int getNetworkTimeout() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"getNetworkTimeout\");\n    }\n    \n    @Override\n    public void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"setNetworkTimeout\");\n    }\n    \n    @Override\n    public Array createArrayOf(final String typeName, final Object[] elements) throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"createArrayOf\");\n    }\n    \n    @Override\n    public final Blob createBlob() throws SQLException {\n        throw new SQLFeatureNotSupportedException(\"createBlob\");\n    }\n    \n    @Override","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/unsupported/AbstractUnsupportedOperationConnection.java#L61-L97","documentation":"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.","triggerScenarios":"Calling Connection.getNetworkTimeout() on a ShardingSphere connection.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"boolean supportsOp = false;\ntry {\n    connection.getMetaData(); // connection is alive\n    // JDBC has no capability flag for individual methods; probe once per JVM:\n    supportsOp = probeSupport(connection); // reflective/one-time guarded call\n} catch (final SQLException ignored) {\n}\n// Simpler and recommended: capability-check by driver URL\nboolean isShardingSphere = url.startsWith(\"jdbc:shardingsphere:\");\nif (isShardingSphere) {\n    // skip the unsupported call, use the alternative API path\n}","typeGuard":null,"tryCatchPattern":"try {\n    connection.getNetworkTimeout(/* args */);\n} catch (final SQLFeatureNotSupportedException e) {\n    // expected on ShardingSphere connections: fall back to supported API\n    log.debug(\"Driver does not support getNetworkTimeout, using fallback\", e);\n}","preventionTips":["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."],"tags":["jdbc","shardingsphere","unsupported-operation","connection-api"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}