apache/seatunnel · error · SeaTunnelException

Failed to querySQLResult

Error message

Failed to querySQLResult

What it means

AbstractJdbcCatalog wraps any SQLException that occurs while checking whether a database exists into a SeaTunnelException with the generic message 'Failed to querySQLResult'. It indicates the underlying JDBC metadata query (or listDatabases fallback) failed at the connection/SQL level, not that the database is missing.

Source

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

    }

    @Override
    public boolean databaseExists(String databaseName) throws CatalogException {
        if (StringUtils.isBlank(databaseName)) {
            return false;
        }
        try {
            return querySQLResultExists(defaultUrl, getDatabaseWithConditionSql(databaseName));
        } catch (SeaTunnelRuntimeException e) {
            if (e.getSeaTunnelErrorCode().getCode().equals(UNSUPPORTED_METHOD.getCode())) {
                log.warn(
                        "The catalog: {} is not supported the getDatabaseWithConditionSql for databaseExists",
                        this.catalogName);
                return listDatabases().contains(databaseName);
            }
            throw e;
        } catch (SQLException e) {
            throw new SeaTunnelException("Failed to querySQLResult", e);
        }
    }

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

    protected String getTableWithConditionSql(TablePath tablePath) {
        throw CommonError.unsupportedMethod(this.catalogName, "getTableWithConditionSql");
    }

    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;

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Verify the catalog connection URL, username, and password; test connectivity with a plain JDBC client first
  2. Ensure the correct JDBC driver jar is installed in the SeaTunnel plugin directory
  3. Check database server availability and network/firewall rules from the SeaTunnel node
  4. Inspect the wrapped cause (getCause()) for the true SQL error and address it
  5. Retry after confirming the database has recovered if it was a transient outage

Example fix

// before
catalog.databaseExists("mydb");
// after
try {
    boolean exists = catalog.databaseExists("mydb");
} catch (SeaTunnelException e) {
    LOG.error("catalog metadata query failed", e.getCause());
}
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling catalog ops, verify connectivity
try (Connection c = DriverManager.getConnection(url, user, pass)) {
    if (!c.isValid(5)) throw new IllegalStateException("catalog connection invalid");
}

Try / catch

try {
    catalog.databaseExists(db);
} catch (SeaTunnelException e) {
    // inspect e.getCause() (SQLException) and decide retry vs fail
}

Prevention

When it happens

Trigger: Calling databaseExists() (directly or via listTables/listViews/tableExists/createTable/createDatabase/dropDatabase) when the catalog connection is broken, credentials are wrong, the JDBC URL is unreachable, or the driver throws during metadata query execution.

Common situations: Database server down or network partition; wrong username/password in catalog config; driver jar missing from the plugin dir; firewall blocking the metadata port; transient connection pool exhaustion.

Understand the failure class

Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.

Related errors


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