{"record":{"id":"5ce0f52912be6476","repo":"testcontainers/testcontainers-java","slug":"database-name-cannot-be-null-or-empty-oraclecontainer","errorCode":null,"errorMessage":"Database name cannot be null or empty","messagePattern":"Database name cannot be null or empty","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java","lineNumber":172,"sourceCode":"            throw new IllegalArgumentException(\"Username cannot be one of \" + ORACLE_SYSTEM_USERS);\n        }\n        this.username = username;\n        return self();\n    }\n\n    @Override\n    public OracleContainer withPassword(String password) {\n        if (StringUtils.isEmpty(password)) {\n            throw new IllegalArgumentException(\"Password cannot be null or empty\");\n        }\n        this.password = password;\n        return self();\n    }\n\n    @Override\n    public OracleContainer withDatabaseName(String databaseName) {\n        if (StringUtils.isEmpty(databaseName)) {\n            throw new IllegalArgumentException(\"Database name cannot be null or empty\");\n        }\n\n        if (DEFAULT_DATABASE_NAME.equals(databaseName.toLowerCase())) {\n            throw new IllegalArgumentException(\"Database name cannot be set to \" + DEFAULT_DATABASE_NAME);\n        }\n\n        this.databaseName = databaseName;\n        return self();\n    }\n\n    public OracleContainer usingSid() {\n        this.usingSid = true;\n        return self();\n    }\n\n    @Override\n    public OracleContainer withUrlParam(String paramName, String paramValue) {\n        throw new UnsupportedOperationException(\"The Oracle Database driver does not support this\");","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/oracle-xe/src/main/java/org/testcontainers/containers/OracleContainer.java#L154-L190","documentation":"OracleContainer.withDatabaseName() requires a non-null, non-empty database name. Testcontainers creates this database inside the Oracle instance, so an empty name would produce an invalid CREATE DATABASE/initialization; the library throws IllegalArgumentException up front.","triggerScenarios":"Calling container.withDatabaseName(null) or withDatabaseName(\"\") during container configuration.","commonSituations":"Database name templated from an unset property; YAML/properties key misspelling; copying config code and forgetting to fill the placeholder.","solutions":["Supply a real database name, e.g. withDatabaseName(\"mydb\")","Fix the config source so the value resolves non-empty","Omit withDatabaseName to use the container default database"],"exampleFix":"// before\ncontainer.withDatabaseName(props.getProperty(\"db.name\"));\n// after\nString dbName = props.getProperty(\"db.name\", \"mydb\");\ncontainer.withDatabaseName(dbName);","handlingStrategy":"validation","validationCode":"if (dbName == null || dbName.isEmpty()) dbName = \"testdb\";\ncontainer.withDatabaseName(dbName);","typeGuard":"boolean isValidDbName(String n) { return n != null && !n.isEmpty(); }","tryCatchPattern":"try { container.withDatabaseName(name); } catch (IllegalArgumentException e) { /* omit custom name, use default */ }","preventionTips":["Provide fallback defaults for DB names in test config","Validate properties files at startup","Avoid passing raw property lookups straight into builders"],"tags":["oracle","testcontainers","validation"],"backgroundTag":"empty-required-field","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}