{"record":{"id":"d854ff36812ddc1f","repo":"apache/seatunnel","slug":"failed-to-querysqlresult","errorCode":null,"errorMessage":"Failed to querySQLResult","messagePattern":"Failed to querySQLResult","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java","lineNumber":377,"sourceCode":"    }\n\n    @Override\n    public boolean databaseExists(String databaseName) throws CatalogException {\n        if (StringUtils.isBlank(databaseName)) {\n            return false;\n        }\n        try {\n            return querySQLResultExists(defaultUrl, getDatabaseWithConditionSql(databaseName));\n        } catch (SeaTunnelRuntimeException e) {\n            if (e.getSeaTunnelErrorCode().getCode().equals(UNSUPPORTED_METHOD.getCode())) {\n                log.warn(\n                        \"The catalog: {} is not supported the getDatabaseWithConditionSql for databaseExists\",\n                        this.catalogName);\n                return listDatabases().contains(databaseName);\n            }\n            throw e;\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\"Failed to querySQLResult\", e);\n        }\n    }\n\n    protected String getListTableSql(String databaseName) {\n        throw new UnsupportedOperationException();\n    }\n\n    protected String getTableWithConditionSql(TablePath tablePath) {\n        throw CommonError.unsupportedMethod(this.catalogName, \"getTableWithConditionSql\");\n    }\n\n    protected String getTableName(ResultSet rs) throws SQLException {\n        String schemaName = rs.getString(1);\n        String tableName = rs.getString(2);\n        if (StringUtils.isNotBlank(schemaName)) {\n            return schemaName + \".\" + tableName;\n        }\n        return null;","sourceCodeStart":359,"sourceCodeEnd":395,"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#L359-L395","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the catalog connection URL, username, and password; test connectivity with a plain JDBC client first","Ensure the correct JDBC driver jar is installed in the SeaTunnel plugin directory","Check database server availability and network/firewall rules from the SeaTunnel node","Inspect the wrapped cause (getCause()) for the true SQL error and address it","Retry after confirming the database has recovered if it was a transient outage"],"exampleFix":"// before\ncatalog.databaseExists(\"mydb\");\n// after\ntry {\n    boolean exists = catalog.databaseExists(\"mydb\");\n} catch (SeaTunnelException e) {\n    LOG.error(\"catalog metadata query failed\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":"// before calling catalog ops, verify connectivity\ntry (Connection c = DriverManager.getConnection(url, user, pass)) {\n    if (!c.isValid(5)) throw new IllegalStateException(\"catalog connection invalid\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.databaseExists(db);\n} catch (SeaTunnelException e) {\n    // inspect e.getCause() (SQLException) and decide retry vs fail\n}","preventionTips":["Test catalog connectivity with a plain JDBC client before running jobs","Install the correct driver jar in the plugin directory","Validate catalog URL/credentials in config before submission","Monitor database health from SeaTunnel nodes (network/firewall)"],"tags":["jdbc","catalog","sql-exception","connectivity"],"backgroundTag":"sql-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}