{"record":{"id":"8cf0b952e5ed9919","repo":"apache/seatunnel","slug":"failed-dropping-database-s-in-catalog-s","errorCode":null,"errorMessage":"Failed dropping database %s in catalog %s","messagePattern":"Failed dropping database (.+?) in catalog (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java","lineNumber":624,"sourceCode":"\n        if (!databaseExists(tablePath.getDatabaseName())) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new DatabaseNotExistException(catalogName, tablePath.getDatabaseName());\n        }\n        dropDatabaseInternal(tablePath.getDatabaseName());\n    }\n\n    protected String getDropDatabaseSql(String databaseName) {\n        throw new UnsupportedOperationException();\n    }\n\n    protected void dropDatabaseInternal(String databaseName) throws CatalogException {\n        try {\n            executeInternal(defaultUrl, getDropDatabaseSql(databaseName));\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\n                            \"Failed dropping database %s in catalog %s\",\n                            databaseName, this.catalogName),\n                    e);\n        }\n    }\n\n    protected String getUrlFromDatabaseName(String databaseName) {\n        String url = baseUrl.endsWith(\"/\") ? baseUrl : baseUrl + \"/\";\n        return url + databaseName + suffix;\n    }\n\n    protected String getOptionTableName(TablePath tablePath) {\n        return tablePath.getFullName();\n    }\n\n    @SuppressWarnings(\"MagicNumber\")\n    protected Map<String, String> buildConnectorOptions(TablePath tablePath) {","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java#L606-L642","documentation":"Thrown by AbstractJdbcCatalog.dropDatabaseInternal when executing the dialect-specific DROP DATABASE SQL over the default JDBC URL fails; wraps the SQLException with the database and catalog named in the message.","triggerScenarios":"catalog.dropDatabase(tablePath, false) on an existing database where executeInternal(defaultUrl, getDropDatabaseSql(...)) throws: privilege denied, database not empty (dialect requires CASCADE), active connections blocking drop, or connection failure.","commonSituations":"User lacks DROP privileges on the database; databases with dependent objects on engines requiring CASCADE; other sessions connected to the database (e.g. MySQL/Postgres refusing drop); defaultUrl pointing at the wrong server.","solutions":["Read the wrapped cause exception for the driver-level reason.","Grant DROP privileges to the catalog user.","Disconnect other sessions from the database, or add CASCADE where the dialect supports it (override getDropDatabaseSql).","Verify defaultUrl targets the correct server and the database exists there.","Execute the DROP DATABASE statement manually with the same credentials to reproduce."],"exampleFix":"// before\ncatalog.dropDatabase(TablePath.of(\"busydb\"), false); // fails, sessions active\n// after\n// override in dialect subclass:\n@Override\nprotected String getDropDatabaseSql(String databaseName) {\n    return String.format(\"DROP DATABASE IF EXISTS %s\", databaseName);\n}","handlingStrategy":"try-catch","validationCode":"if (!catalog.databaseExists(dbName)) return; // already gone","typeGuard":null,"tryCatchPattern":"try { catalog.dropDatabase(path, false); } catch (CatalogException e) { Throwable c = e.getCause(); LOG.error(\"Drop DB {} failed: {}\", dbName, c != null ? c.getMessage() : e.getMessage(), e); }","preventionTips":["Grant DROP privileges to the catalog user","Terminate dependent sessions before dropping","Use CASCADE-capable DDL where the dialect allows","Test the drop statement manually with the same credentials"],"tags":["jdbc","catalog","sql","drop-database"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}