{"record":{"id":"a0cba42f6845dde1","repo":"alibaba/druid","slug":"check-connection-info-failed","errorCode":null,"errorMessage":"check connection info failed","messagePattern":"check connection info failed","errorType":"exception","errorClass":"DruidRuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java","lineNumber":261,"sourceCode":"            }\n\n            String connectPassword = password != null ? password : this.password;\n            if (connectPassword != null) {\n                connectProperties.put(\"password\", connectPassword);\n            }\n            connectUrl = url != null ? url : this.jdbcUrl;\n        } finally {\n            lock.unlock();\n        }\n\n        if (urlUserPasswordChanged) {\n            Connection conn = null;\n            try {\n                conn = getDriver().connect(connectUrl, connectProperties);\n                LOG.info(\"check connection info success\");\n                // ignore\n            } catch (SQLException e) {\n                throw new DruidRuntimeException(\"check connection info failed\", e);\n            } finally {\n                JdbcUtils.close(conn);\n            }\n        }\n\n        lock.lock();\n        try {\n            if (urlUserPasswordChanged) {\n                if (url != null && !url.equals(this.jdbcUrl)) {\n                    this.jdbcUrl = url; // direct set url, ignore init check\n                    LOG.info(\"jdbcUrl changed\");\n                }\n\n                if (username != null && !username.equals(this.username)) {\n                    this.username = username; // direct set, ignore init check\n                    LOG.info(\"username changed\");\n                }\n","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidDataSource.java#L243-L279","documentation":"Wrapped as DruidRuntimeException when, during a url/username/password change on an already-initialized datasource (urlUserPasswordChanged branch), Druid opens a probe connection via getDriver().connect(connectUrl, connectProperties) and that connect() throws SQLException. The probe verifies the new credentials before committing them; failure aborts the change.","triggerScenarios":"Calling setUrl/setUsername/setPassword on an inited datasource triggers the urlUserPasswordChanged block at line 254; getDriver().connect() throws SQLException at line 257, caught at 260 and rethrown wrapped at 261.","commonSituations":"Rotating DB credentials at runtime with wrong password; pointing an inited datasource at a new url that is unreachable; new credentials lacking connect permission; network/firewall blocking the probe connect.","solutions":["Verify the new url/username/password connect manually (psql, mysql client, or a small JDBC snippet) before calling the setter.","Check network reachability and DB grants for the new credentials.","If you must reconfigure wholesale, prefer close()+restart(properties) over mutating an inited pool.","Catch DruidRuntimeException around the setter to surface the wrapped SQLException cause for the real DB error."],"exampleFix":"// before\ndataSource.setUsername(\"appuser\");\ndataSource.setPassword(\"typo-password\"); // probe connect fails -> wrapped exception\n// after\n// validate first\ntry (Connection c = DriverManager.getConnection(newUrl, \"appuser\", correctPwd)) {\n    // ok\n}\ndataSource.setUsername(\"appuser\");\ndataSource.setPassword(correctPwd);","handlingStrategy":"try-catch","validationCode":"// Pre-validate the new credentials before pushing them into the inited pool\ntry (Connection probe = DriverManager.getConnection(newUrl, newUser, newPass)) {\n    // connect ok\n} catch (SQLException e) {\n    throw new IllegalArgumentException(\"new credentials invalid\", e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    dataSource.setUsername(newUser);\n    dataSource.setPassword(newPass);\n} catch (com.alibaba.druid.support.logging.DruidRuntimeException e) {\n    if (e.getMessage().contains(\"check connection info failed\")) {\n        // wrapped SQLException cause has the real DB error\n        throw new IllegalStateException(\"credential rotation failed\", e.getCause());\n    }\n    throw e;\n}","preventionTips":["Validate credentials with a probe connection before mutating an inited datasource.","Prefer close()+new datasource for full reconfiguration.","Surface the wrapped cause to operators."],"tags":["config","credentials","connection","runtime-reconfig"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}