apache/seatunnel · error · CatalogException

Failed creating database %s in catalog %s

Error message

Failed creating database %s in catalog %s

What it means

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.

Source

Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java:569

        if (databaseExists(tablePath.getDatabaseName())) {
            if (ignoreIfExists) {
                return;
            }
            throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());
        }

        createDatabaseInternal(tablePath.getDatabaseName());
    }

    protected String getCreateDatabaseSql(String databaseName) {
        throw new UnsupportedOperationException();
    }

    protected void createDatabaseInternal(String databaseName) {
        try {
            executeInternal(defaultUrl, getCreateDatabaseSql(databaseName));
        } catch (Exception e) {
            throw new CatalogException(
                    String.format(
                            "Failed creating database %s in catalog %s",
                            databaseName, this.catalogName),
                    e);
        }
    }

    protected void closeDatabaseConnection(String databaseName) {
        String dbUrl = getUrlFromDatabaseName(databaseName);
        try {
            Connection connection = connectionMap.remove(dbUrl);
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            throw new CatalogException(String.format("Failed to close %s via JDBC.", dbUrl), e);
        }
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Inspect the wrapped cause exception for the driver-level reason.
  2. Grant CREATE privileges on the server for the catalog user.
  3. Validate the database name against the DBMS identifier rules.
  4. Verify defaultUrl connectivity (test with a simple query).
  5. Create the database manually with a DB client using the same DDL.

Example fix

// before
String name = "my-db"; // hyphen illegal in unquoted MySQL identifier
catalog.createDatabase(TablePath.of(name), false);
// after
catalog.createDatabase(TablePath.of("my_db"), false);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!catalog.databaseExists(dbName) && catalog.listDatabases() != null) { /* proceed cautiously */ }

Try / catch

try { catalog.createDatabase(path, false); } catch (CatalogException e) { throw new RuntimeException("Create DB " + dbName + " failed: " + e.getCause(), e); }

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/f700ed9cdbf7c3d3. Report an issue: GitHub.