{"record":{"id":"efee2f295a93e864","repo":"apache/seatunnel","slug":"failed-to-querysqlresult-efee2f","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/saphana/SapHanaCatalog.java","lineNumber":202,"sourceCode":"                                this.getUrlFromDatabaseName(tablePath.getDatabaseName()),\n                                String.format(\n                                        getListViewSql(tablePath.getDatabaseName())\n                                                + \" AND VIEW_NAME = '%s'\",\n                                        tablePath.getTableName()))\n                        || querySQLResultExists(\n                                this.getUrlFromDatabaseName(tablePath.getDatabaseName()),\n                                String.format(\n                                        getListSynonymSql(tablePath.getDatabaseName())\n                                                + \" AND SYNONYM_NAME = '%s'\",\n                                        tablePath.getSchemaAndTableName()));\n            }\n            return querySQLResultExists(\n                    this.getUrlFromDatabaseName(tablePath.getDatabaseName()),\n                    getTableWithConditionSql(tablePath));\n        } catch (DatabaseNotExistException e) {\n            return false;\n        } catch (SQLException e) {\n            throw new SeaTunnelException(\"Failed to querySQLResult\", e);\n        }\n    }\n\n    public CatalogTable getTable(TablePath tablePath)\n            throws CatalogException, TableNotExistException {\n        if (!tableExists(tablePath)) {\n            throw new TableNotExistException(catalogName, tablePath);\n        }\n        String dbUrl;\n        if (StringUtils.isNotBlank(tablePath.getDatabaseName())) {\n            dbUrl = getUrlFromDatabaseName(tablePath.getDatabaseName());\n        } else {\n            dbUrl = getUrlFromDatabaseName(defaultDatabase);\n        }\n        Connection conn = getConnection(dbUrl);\n        TablePath originalTablePath = tablePath;\n        if (listSynonym(tablePath.getDatabaseName()).contains(tablePath.getTableName())) {\n            String sql =","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/saphana/SapHanaCatalog.java#L184-L220","documentation":"SapHanaCatalog.tableExists() wraps any SQLException thrown while running the table-existence probe query into a SeaTunnelException with the message 'Failed to querySQLResult'. This means the JDBC metadata lookup itself failed (connection problem, bad credentials, malformed URL, or SQL error), rather than the table simply not existing. The DatabaseNotExistException path is caught separately and safely returns false, so this exception indicates a genuine query failure.","triggerScenarios":"Calling SapHanaCatalog.tableExists (directly or indirectly via getTable) when the JDBC connection to SAP HANA drops mid-query, credentials are invalid, the database name does not map to a valid HANA URL, or the generated getTableWithConditionSql SQL is rejected by the server (e.g. special characters in schema/table names breaking the condition SQL).","commonSituations":"Network/firewall issues between SeaTunnel and the HANA instance; wrong username/password in catalog config; using a databaseName that is not a valid HANA tenant database; table/schema identifiers containing quotes that break the hand-built SQL string.","solutions":["Check the wrapped SQLException cause for the root reason (connect timeout, auth failure, SQL syntax).","Verify the JDBC URL and databaseName resolve correctly (getUrlFromDatabaseName) and the HANA instance is reachable on the SQL port.","Test connectivity with a plain JDBC client (e.g. DBeaver or a small Java snippet) using the same URL/credentials.","Escape or sanitize schema/table names in the TablePath so the generated condition SQL is valid."],"exampleFix":"// before\ntry {\n    exists = catalog.tableExists(TablePath.of(db, \"my$table\"));\n} catch (SeaTunnelException e) { /* opaque */ }\n// after\nTablePath tp = TablePath.of(\"MYDB\", \"MY_TABLE\"); // sanitized, uppercase HANA identifiers\nif (!catalog.databaseExists(tp.getDatabaseName())) {\n    throw new IllegalArgumentException(\"database not reachable: \" + tp.getDatabaseName());\n}\nboolean exists = catalog.tableExists(tp);","handlingStrategy":"try-catch","validationCode":"// java\nif (!catalog.databaseExists(tablePath.getDatabaseName())) {\n    throw new IllegalArgumentException(\"database unreachable/missing: \" + tablePath.getDatabaseName());\n}","typeGuard":null,"tryCatchPattern":"// java\ntry {\n    boolean exists = catalog.tableExists(tablePath);\n} catch (SeaTunnelException e) {\n    Throwable root = e.getCause(); // SQLException with real reason\n    LOG.error(\"HANA tableExists probe failed\", root);\n    throw new RuntimeException(\"metadata probe failed: \" + root.getMessage(), e);\n}","preventionTips":["Verify HANA connectivity and credentials with a standalone JDBC client before running the job.","Use uppercase, unquoted-safe identifiers in TablePath (HANA default catalog rules).","Ensure the databaseName maps to a valid tenant DB URL."],"tags":["jdbc","sap-hana","catalog","sql"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}