apache/seatunnel · error · DatabaseAlreadyExistException
DatabaseAlreadyExistException: catalogName, databaseName
Error message
DatabaseAlreadyExistException: catalogName, databaseName
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/catalog/DatabendCatalog.java:358
Statement statement = connection.createStatement()) {
statement.execute(dropTableSql);
} catch (SQLException e) {
throw new DatabendConnectorException(
DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
"Failed to drop table: " + e.getMessage(),
e);
}
}
public void createDatabase(String databaseName, boolean ignoreIfExists)
throws DatabaseAlreadyExistException, CatalogException {
checkOpen();
if (databaseExists(databaseName)) {
if (ignoreIfExists) {
return;
}
throw new DatabaseAlreadyExistException(catalogName, databaseName);
}
String createDatabaseSql = String.format("CREATE DATABASE %s", databaseName);
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
statement.execute(createDatabaseSql);
} catch (SQLException e) {
throw new DatabendConnectorException(
DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
"Failed to create database: " + e.getMessage(),
e);
}
}
public void dropDatabase(String databaseName, boolean ignoreIfNotExists)
throws DatabaseNotExistException, CatalogException {
checkOpen();View on GitHub (pinned to cf67b549a7)
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.
Example fix
// before
catalog.createDatabase("analytics", false); // throws on second run
// after
catalog.createDatabase("analytics", true); // idempotent bootstrap Defensive patterns
Strategy: validation
Validate before calling
if (!catalog.databaseExists(dbName)) { catalog.createDatabase(dbName, false); } Try / catch
try { catalog.createDatabase(dbName, false); } catch (DatabaseAlreadyExistException e) { log.info("Database {} already exists", dbName); } Prevention
- Pass ignoreIfExists=true in bootstrap scripts
- Make setup scripts re-runnable
- Use per-run database names for isolation
When it happens
Trigger: Calling createDatabase(databaseName, ignoreIfExists=false) when databaseExists(databaseName) is true — database was created previously by setup scripts or a prior run.
Common situations: Bootstrap scripts run twice without idempotency flags; shared environments where the database already exists; migrating jobs that assume a fresh cluster.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- CONNECT_FAILED
- DatabaseNotExistException: catalogName, databaseName
- TableNotExistException: catalogName, tablePath
- TableAlreadyExistException: catalogName, tablePath
- UNSUPPORTED_DATA_TYPE
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/41a487b317cb24e5.
Report an issue: GitHub.