{"record":{"id":"6c8050aaa4878810","repo":"apache/seatunnel","slug":"database-databasename-does-not-exist-in-catalog-6c8050","errorCode":null,"errorMessage":"Database ${databaseName} does not exist in catalog ${name()}","messagePattern":"Database (.+?) does not exist in catalog (.+?)","errorType":"exception","errorClass":"DatabaseNotExistException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java","lineNumber":100,"sourceCode":"\n    @Override\n    public List<String> listDatabases() throws CatalogException {\n        try {\n            List<String> dbs = new ArrayList<>();\n            for (String name : mongoClient.listDatabaseNames()) {\n                dbs.add(name);\n            }\n            return dbs;\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to list databases\", e);\n        }\n    }\n\n    @Override\n    public List<String> listTables(String databaseName)\n            throws CatalogException, DatabaseNotExistException {\n        if (!databaseExists(databaseName)) {\n            throw new DatabaseNotExistException(name(), databaseName);\n        }\n        try {\n            MongoDatabase db = mongoClient.getDatabase(databaseName);\n            return db.listCollectionNames().into(new ArrayList<>());\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to list tables for database: \" + databaseName, e);\n        }\n    }\n\n    @Override\n    public boolean tableExists(TablePath tablePath) throws CatalogException {\n        try {\n            return listTables(tablePath.getDatabaseName()).contains(tablePath.getTableName());\n        } catch (DatabaseNotExistException e) {\n            return false;\n        }\n    }\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-mongodb/src/main/java/org/apache/seatunnel/connectors/seatunnel/mongodb/catalog/MongodbCatalog.java#L82-L118","documentation":"listTables(databaseName) first checks databaseExists(databaseName); if the database is not present in the MongoDB server's database list, it throws DatabaseNotExistException naming the catalog and database. This is a pre-check failure, not a driver failure.","triggerScenarios":"Calling listTables with a database name that does not exist on the server, or a name with a typo/different case, or when listDatabases fails internally making the database appear missing (insufficient privileges can hide databases).","commonSituations":"Typo in database name in the job config, MongoDB auth restricting visible databases so databaseExists returns false, case-sensitive name mismatch (MongoDB names are case-sensitive).","solutions":["Confirm the database name spelling and casing exactly matches the server (show dbs / db.getMongo().getDBs()).","Check that the connected user has privileges to see the database (listDatabases on admin).","Create the database/collection first, or use a catalog option that creates it if missing.","If privileges hide it, grant the user clusterMonitor role."],"exampleFix":"// before\nList<String> tables = catalog.listTables(\"MyDB\");\n// after\nList<String> dbs = catalog.listDatabases();\nif (dbs.contains(\"MyDB\")) {\n    List<String> tables = catalog.listTables(\"MyDB\");\n}","handlingStrategy":"validation","validationCode":"if (!catalog.databaseExists(TablePath.of(db, \"_\"))) {\n    throw new IllegalArgumentException(\"DB missing: \" + db);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.listTables(dbName);\n} catch (DatabaseNotExistException e) {\n    // create DB or fix name\n}","preventionTips":["Copy database names from listDatabases() instead of typing them","Remember MongoDB names are case-sensitive","Verify auth user can see the database","Create databases explicitly before listing tables"],"tags":["mongodb","catalog","database-not-exist"],"backgroundTag":"entity-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}