apache/seatunnel · error · DatabaseNotExistException

Database 'null' does not exist in catalog 'null'

Error message

Database 'null' does not exist in catalog 'null'

What it means

listTables throws DatabaseNotExistException when databaseExists() returns false for the requested databaseName. The message embeds the catalog name and database name (rendered as 'null' here because those arguments were null/unset in this trace). It signals the target database/schema does not exist before any table listing query runs.

Source

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

    protected String getTableName(ResultSet rs) throws SQLException {
        String schemaName = rs.getString(1);
        String tableName = rs.getString(2);
        if (StringUtils.isNotBlank(schemaName)) {
            return schemaName + "." + tableName;
        }
        return null;
    }

    protected String getTableName(TablePath tablePath) {
        return tablePath.getSchemaAndTableName();
    }

    @Override
    public List<String> listTables(String databaseName)
            throws CatalogException, DatabaseNotExistException {
        if (!databaseExists(databaseName)) {
            throw new DatabaseNotExistException(this.catalogName, databaseName);
        }

        String dbUrl = getUrlFromDatabaseName(databaseName);
        try {
            return queryString(dbUrl, getListTableSql(databaseName), this::getTableName);
        } catch (Exception e) {
            throw new CatalogException(
                    String.format("Failed listing database in catalog %s", catalogName), e);
        }
    }

    public List<String> listViews(String databaseName)
            throws CatalogException, DatabaseNotExistException {
        if (!databaseExists(databaseName)) {
            throw new DatabaseNotExistException(this.catalogName, databaseName);
        }
        String dbUrl = getUrlFromDatabaseName(databaseName);
        try {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify the database name spelling and case against the actual server (SHOW DATABASES / \l)
  2. Confirm the catalog URL points at the intended server and instance
  3. Create the database first with catalog.createDatabase() or an admin DDL statement
  4. If probing, call tableExists() with ignore-style handling or catch DatabaseNotExistException and treat as false

Example fix

// before
catalog.listTables("MyDB"); // case mismatch on postgres
// after
catalog.listTables("mydb"); // use exact server-side name
Defensive patterns

Strategy: validation

Validate before calling

if (!catalog.databaseExists(databaseName)) {
    throw new IllegalArgumentException("database not found: " + databaseName);
}

Try / catch

try {
    return catalog.listTables(db);
} catch (DatabaseNotExistException e) {
    return Collections.emptyList();
}

Prevention

When it happens

Trigger: Calling listTables(databaseName) with a database name that does not exist in the target JDBC catalog — typically via tableExists() with a misspelled or non-existent database in a TablePath.

Common situations: Typos in the database name in the config file; connecting to a different database server than intended (e.g. wrong URL pointing at an empty instance); case-sensitivity mismatch on databases like PostgreSQL where names are lowercased.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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