{"record":{"id":"41a487b317cb24e5","repo":"apache/seatunnel","slug":"databasealreadyexistexception-catalogname-databa","errorCode":null,"errorMessage":"DatabaseAlreadyExistException: catalogName, databaseName","messagePattern":"DatabaseAlreadyExistException: catalogName, databaseName","errorType":"error_code","errorClass":"DatabaseAlreadyExistException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/catalog/DatabendCatalog.java","lineNumber":358,"sourceCode":"                Statement statement = connection.createStatement()) {\n            statement.execute(dropTableSql);\n        } catch (SQLException e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,\n                    \"Failed to drop table: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    public void createDatabase(String databaseName, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        checkOpen();\n\n        if (databaseExists(databaseName)) {\n            if (ignoreIfExists) {\n                return;\n            }\n            throw new DatabaseAlreadyExistException(catalogName, databaseName);\n        }\n\n        String createDatabaseSql = String.format(\"CREATE DATABASE %s\", databaseName);\n\n        try (Connection connection = getConnection();\n                Statement statement = connection.createStatement()) {\n            statement.execute(createDatabaseSql);\n        } catch (SQLException e) {\n            throw new DatabendConnectorException(\n                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,\n                    \"Failed to create database: \" + e.getMessage(),\n                    e);\n        }\n    }\n\n    public void dropDatabase(String databaseName, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        checkOpen();","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/catalog/DatabendCatalog.java#L340-L376","documentation":"createDatabase() throws the standard SeaTunnel DatabaseAlreadyExistException when the requested database already exists in Databend and ignoreIfExists is false. The catalog pre-checks existence instead of relying on the server's error.","triggerScenarios":"Calling createDatabase(databaseName, ignoreIfExists=false) when databaseExists(databaseName) is true — database was created previously by setup scripts or a prior run.","commonSituations":"Bootstrap scripts run twice without idempotency flags; shared environments where the database already exists; migrating jobs that assume a fresh cluster.","solutions":["Pass ignoreIfExists=true to skip creation when the database is already present.","Drop the existing database first if a fresh one is required (destructive).","Use a distinct database name for isolated runs."],"exampleFix":"// before\ncatalog.createDatabase(\"analytics\", false); // throws on second run\n// after\ncatalog.createDatabase(\"analytics\", true); // idempotent bootstrap","handlingStrategy":"validation","validationCode":"if (!catalog.databaseExists(dbName)) { catalog.createDatabase(dbName, false); }","typeGuard":null,"tryCatchPattern":"try { catalog.createDatabase(dbName, false); } catch (DatabaseAlreadyExistException e) { log.info(\"Database {} already exists\", dbName); }","preventionTips":["Pass ignoreIfExists=true in bootstrap scripts","Make setup scripts re-runnable","Use per-run database names for isolation"],"tags":["database-already-exist","databend","catalog","create-database"],"backgroundTag":"file-already-exists","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"}