{"record":{"id":"45c2e9d8b3e3cd94","repo":"alibaba/druid","slug":"wait-millis-waitmillis-active-activecount-ma","errorCode":null,"errorMessage":"wait millis {waitMillis}, active {activeCount}, maxActive {maxActive}, creating {creatingCount}","messagePattern":"wait millis (.+?), active (.+?), maxActive (.+?), creating (.+?)","errorType":"exception","errorClass":"GetConnectionTimeoutException","httpStatus":null,"severity":"critical","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java","lineNumber":1769,"sourceCode":"            }\n\n            List<JdbcSqlStatValue> sqlList = this.getDataSourceStat().getRuningSqlList();\n            for (int i = 0; i < sqlList.size(); ++i) {\n                if (i != 0) {\n                    buf.append('\\n');\n                } else {\n                    buf.append(\", \");\n                }\n                JdbcSqlStatValue sql = sqlList.get(i);\n                buf.append(\"runningSqlCount \").append(sql.getRunningCount());\n                buf.append(\" : \");\n                buf.append(sql.getSql());\n            }\n\n            String errorMessage = buf.toString();\n\n            if (createError != null) {\n                throw new GetConnectionTimeoutException(errorMessage, createError);\n            } else {\n                throw new GetConnectionTimeoutException(errorMessage);\n            }\n        }\n\n        holder.incrementUseCount();\n\n        return new DruidPooledConnection(holder);\n    }\n\n    public void handleConnectionException(\n            DruidPooledConnection pooledConnection,\n            Throwable t,\n            String sql\n    ) throws SQLException {\n        final DruidConnectionHolder holder = pooledConnection.getConnectionHolder();\n        if (holder == null) {\n            return;","sourceCodeStart":1751,"sourceCodeEnd":1787,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java#L1751-L1787","documentation":"GetConnectionTimeoutException (a SQLException subclass) thrown from getConnection() when no pooled connection could be obtained within maxWait, AND the pool had previously recorded a connection-creation error (createError != null). The creation error is chained as the cause, so this is really a 'pool exhausted because creation is failing' diagnosis: the real reason lives in the cause.","triggerScenarios":"holder is null after the wait loop (line 1714), createError field is non-null (a prior createPhysicalConnection attempt threw), so line 1769 fires. Produces a message like 'wait millis X, active Y, maxActive Z, creating W, createErrorCount N' plus the chained createError. Happens when the DB is unreachable/unauthenticated and the pool simultaneously empties out.","commonSituations":"Wrong DB url/credentials/host/port; DB down or refusing connections; firewall dropping the socket so every creation attempt fails while in-flight requests drain the pool; driver class/version mismatch causing creation errors; maxActive saturated while create keeps erroring.","solutions":["Read getNextException / getCause() of the thrown GetConnectionTimeoutException — the createError there is the actual failure (auth refused, connection refused, socket timeout).","Verify jdbcUrl, username, password, driver class and network reachability to the DB host/port (telnet/nc) from the app host.","Confirm the JDBC driver jar matches the DB version and is on the classpath; check DriverManager can create a raw connection with the same URL outside the pool.","Tune maxActive / maxWait upward only after the creation error is fixed; a saturated-but-healthy pool throws error 44, not this one."],"exampleFix":"// before: root cause hidden\ncatch (GetConnectionTimeoutException e) { log.error(e.getMessage()); }\n\n// after: surface the chained creation error\ncatch (GetConnectionTimeoutException e) {\n    Throwable cause = e.getCause();\n    log.error(\"pool borrow timed out; underlying create error: {}\", cause, cause);\n}","handlingStrategy":"try-catch","validationCode":"// preflight: can we even open a raw connection with these credentials/url?\n// run once at startup, not per request\ntry (Connection raw = DriverManager.getConnection(jdbcUrl, user, pwd)) {\n    assert raw.isValid(2);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return dataSource.getConnection();\n} catch (GetConnectionTimeoutException e) {\n    Throwable cause = e.getCause();\n    if (cause != null) {\n        // createError is the real reason (auth refused, connection refused)\n        log.error(\"borrow timed out due to create failure: {}\", cause);\n    }\n    throw e;\n}","preventionTips":["Always log getCause() of a GetConnectionTimeoutException — it distinguishes error 43 from 44.","Validate connectivity at startup with a raw DriverManager probe.","Keep the driver jar matched to the DB version and on the classpath."],"tags":["getconnection-timeout","connection-pool","create-error","chained-cause","database-connectivity"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}