{"record":{"id":"575c7aa34c3fd4fa","repo":"quarkusio/quarkus","slug":"username-and-password-must-be-defined-when-a-jdbc","errorCode":null,"errorMessage":"Username and password must be defined when a JDBC URL is provided in the Flyway configuration","messagePattern":"Username and password must be defined when a JDBC URL is provided in the Flyway configuration","errorType":"exception","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java","lineNumber":60,"sourceCode":"        this.flywayRuntimeConfig = flywayRuntimeConfig;\n        this.flywayBuildTimeConfig = flywayBuildTimeConfig;\n        this.customizers = customizers;\n    }\n\n    public FlywayCreator withCallbacks(Collection<Callback> callbacks) {\n        this.callbacks = callbacks;\n        return this;\n    }\n\n    public Flyway createFlyway(DataSource dataSource) {\n        FluentConfiguration configure = Flyway.configure();\n\n        if (flywayRuntimeConfig.jdbcUrl().isPresent()) {\n            if (flywayRuntimeConfig.username().isPresent() && flywayRuntimeConfig.password().isPresent()) {\n                configure.dataSource(flywayRuntimeConfig.jdbcUrl().get(), flywayRuntimeConfig.username().get(),\n                        flywayRuntimeConfig.password().get());\n            } else {\n                throw new ConfigurationException(\n                        \"Username and password must be defined when a JDBC URL is provided in the Flyway configuration\");\n            }\n        } else {\n            if (flywayRuntimeConfig.username().isPresent() && flywayRuntimeConfig.password().isPresent()) {\n                AgroalDataSource agroalDataSource = (AgroalDataSource) dataSource;\n                String jdbcUrl = agroalDataSource.getConfiguration().connectionPoolConfiguration()\n                        .connectionFactoryConfiguration().jdbcUrl();\n\n                configure.dataSource(jdbcUrl, flywayRuntimeConfig.username().get(),\n                        flywayRuntimeConfig.password().get());\n            } else if (dataSource != null) {\n                configure.dataSource(dataSource);\n            }\n        }\n        if (flywayRuntimeConfig.initSql().isPresent()) {\n            configure.initSql(flywayRuntimeConfig.initSql().get());\n        }\n        if (flywayRuntimeConfig.connectRetries().isPresent()) {","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/flyway/runtime/src/main/java/io/quarkus/flyway/runtime/FlywayCreator.java#L42-L78","documentation":"When Flyway is configured with an explicit JDBC URL, Quarkus creates a dedicated DataSource for Flyway, which requires both username and password. If only the URL (or the URL plus only one credential) is present, a ConfigurationException is thrown.","triggerScenarios":"quarkus.flyway.jdbc-url is set but quarkus.flyway.username and quarkus.flyway.password are not both set (or only one of them is).","commonSituations":"Pointing Flyway at a database different from the default Agroal datasource; password supplied only via env var that is absent; assuming Flyway inherits the datasource credentials when jdbc-url is set.","solutions":["Set both quarkus.flyway.username and quarkus.flyway.password alongside quarkus.flyway.jdbc-url","Remove quarkus.flyway.jdbc-url to let Flyway reuse the default Quarkus datasource credentials instead","Verify the environment variables referenced by the properties are actually present in the deployment environment"],"exampleFix":"// before\nquarkus.flyway.jdbc-url=jdbc:postgresql://db:5432/mydb\n// after\nquarkus.flyway.jdbc-url=jdbc:postgresql://db:5432/mydb\nquarkus.flyway.username=flyway\nquarkus.flyway.password=${FLYWAY_PASSWORD}","handlingStrategy":"validation","validationCode":"if (jdbcUrl != null && (username == null || password == null)) {\n    throw new IllegalArgumentException(\"quarkus.flyway.jdbc-url requires both username and password\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    flyway.migrate();\n} catch (ConfigurationException e) {\n    log.error(\"Flyway JDBC credentials missing: \" + e.getMessage());\n    throw e;\n}","preventionTips":["Set all three: jdbc-url, username, password — or none and reuse the default datasource","Verify referenced env vars exist in each deployment environment","Document Flyway credentials separately from datasource credentials"],"tags":["flyway","configuration","database","jdbc"],"backgroundTag":"missing-required-config","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}