{"record":{"id":"f700ed9cdbf7c3d3","repo":"apache/seatunnel","slug":"failed-creating-database-s-in-catalog-s","errorCode":null,"errorMessage":"Failed creating database %s in catalog %s","messagePattern":"Failed creating 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":569,"sourceCode":"        if (databaseExists(tablePath.getDatabaseName())) {\n            if (ignoreIfExists) {\n                return;\n            }\n            throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());\n        }\n\n        createDatabaseInternal(tablePath.getDatabaseName());\n    }\n\n    protected String getCreateDatabaseSql(String databaseName) {\n        throw new UnsupportedOperationException();\n    }\n\n    protected void createDatabaseInternal(String databaseName) {\n        try {\n            executeInternal(defaultUrl, getCreateDatabaseSql(databaseName));\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\n                            \"Failed creating database %s in catalog %s\",\n                            databaseName, this.catalogName),\n                    e);\n        }\n    }\n\n    protected void closeDatabaseConnection(String databaseName) {\n        String dbUrl = getUrlFromDatabaseName(databaseName);\n        try {\n            Connection connection = connectionMap.remove(dbUrl);\n            if (connection != null) {\n                connection.close();\n            }\n        } catch (SQLException e) {\n            throw new CatalogException(String.format(\"Failed to close %s via JDBC.\", dbUrl), e);\n        }\n    }","sourceCodeStart":551,"sourceCodeEnd":587,"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#L551-L587","documentation":"Thrown by AbstractJdbcCatalog.createDatabaseInternal when executing the dialect-specific CREATE DATABASE SQL over the default JDBC URL fails; it wraps the SQLException and names the database and catalog involved.","triggerScenarios":"catalog.createDatabase(tablePath, ignoreIfExists=false with non-existent DB) where executeInternal(defaultUrl, getCreateDatabaseSql(...)) throws: permission denied, invalid database name characters, connection failure, or unsupported DDL.","commonSituations":"User lacks CREATE privileges; database name contains characters illegal for the DBMS; defaultUrl misconfigured so DDL goes to a wrong/unreachable server; dialect-specific keyword conflicts (e.g. reserved names).","solutions":["Inspect the wrapped cause exception for the driver-level reason.","Grant CREATE privileges on the server for the catalog user.","Validate the database name against the DBMS identifier rules.","Verify defaultUrl connectivity (test with a simple query).","Create the database manually with a DB client using the same DDL."],"exampleFix":"// before\nString name = \"my-db\"; // hyphen illegal in unquoted MySQL identifier\ncatalog.createDatabase(TablePath.of(name), false);\n// after\ncatalog.createDatabase(TablePath.of(\"my_db\"), false);","handlingStrategy":"try-catch","validationCode":"if (!catalog.databaseExists(dbName) && catalog.listDatabases() != null) { /* proceed cautiously */ }","typeGuard":null,"tryCatchPattern":"try { catalog.createDatabase(path, false); } catch (CatalogException e) { throw new RuntimeException(\"Create DB \" + dbName + \" failed: \" + e.getCause(), e); }","preventionTips":["Validate database names against DBMS identifier rules","Ensure CREATE privilege for the catalog user","Test defaultUrl connectivity before DDL operations","Use simple, non-reserved identifiers"],"tags":["jdbc","catalog","sql","create-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"}