{"record":{"id":"886e75514cb6c57c","repo":"apereo/cas","slug":"e-getmessage","errorCode":null,"errorMessage":"[e.getMessage()]","messagePattern":"\\[e\\.getMessage\\(\\)\\]","errorType":"exception","errorClass":"FailedLoginException","httpStatus":null,"severity":"error","filePath":"support/cas-server-support-jdbc-authentication/src/main/java/org/apereo/cas/jdbc/BindModeSearchDatabaseAuthenticationHandler.java","lineNumber":44,"sourceCode":"public class BindModeSearchDatabaseAuthenticationHandler extends AbstractJdbcUsernamePasswordAuthenticationHandler<BindJdbcAuthenticationProperties> {\n\n    public BindModeSearchDatabaseAuthenticationHandler(\n        final BindJdbcAuthenticationProperties properties,\n        final PrincipalFactory principalFactory, final DataSource dataSource) {\n        super(properties, principalFactory, dataSource);\n    }\n\n    @Override\n    protected AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(\n        final UsernamePasswordCredential credential, final String originalPassword) throws Throwable {\n        val username = credential.getUsername();\n        val password = credential.toPassword();\n        try (val connection = getDataSource().getConnection(username, password)) {\n            LOGGER.trace(\"Established connection to schema [{}]\", connection.getSchema());\n            val principal = principalFactory.createPrincipal(username);\n            return createHandlerResult(credential, principal, new ArrayList<>());\n        } catch (final Throwable e) {\n            throw new FailedLoginException(e.getMessage());\n        }\n    }\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-jdbc-authentication/src/main/java/org/apereo/cas/jdbc/BindModeSearchDatabaseAuthenticationHandler.java#L26-L48","documentation":"BindModeSearchDatabaseAuthenticationHandler authenticates by opening a JDBC connection with the username/password as bind credentials. Any Throwable while establishing or using the connection (bad credentials, unreachable DB, driver issues) is converted into FailedLoginException whose message is the original exception's message.","triggerScenarios":"authenticateUsernamePasswordInternal fails at getDataSource().getConnection(username, password) — e.g. database rejects the bind, host/port unreachable, driver class missing — and the caught Throwable's message becomes the thrown error text.","commonSituations":"Wrong password (DB-level auth failure reported verbatim); database down or wrong JDBC URL/host/firewall rules; missing JDBC driver on classpath; using bind mode against a DB (like some MySQL setups) that doesn't support username/password connection auth as expected.","solutions":["Read the embedded message to identify the root cause (auth failure vs connectivity)","Confirm the username/password are valid database credentials directly via a DB client","Check datasource URL/host/port/network reachability and that the JDBC driver is on the classpath","If the DB lacks native password-auth connections, switch to SearchModeSearchDatabaseAuthenticationHandler (query mode) with a service account"],"exampleFix":"// before (bind mode, DB without bind auth)\ncas.authn.jdbc.bind[0].url=jdbc:mysql://db:3306/users\n// after (search mode with service account)\ncas.authn.jdbc.query[0].sql=SELECT * FROM users WHERE username=?\ncas.authn.jdbc.query[0].user=root","handlingStrategy":"try-catch","validationCode":"// precheck connectivity before auth attempt\ntry (var c = dataSource.getConnection()) { /* datasource reachable */ }","typeGuard":null,"tryCatchPattern":"try {\n    return handler.authenticate(credential);\n} catch (FailedLoginException e) {\n    // inspect e.getMessage(): auth failure vs connectivity; alert on connectivity messages\n}","preventionTips":["Validate JDBC URL/host/firewall and driver availability at startup","Test DB credentials with a direct client before blaming the app","Prefer search/query mode with a service account when the DB lacks bind-style auth"],"tags":["jdbc","database","authentication","bind-mode"],"backgroundTag":"database-query-failed","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}