{"record":{"id":"dec71460f4484c23","repo":"apache/seatunnel","slug":"error-dec714","errorCode":null,"errorMessage":"查询数据库是否存在失败: ","messagePattern":"查询数据库是否存在失败: ","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/kingbase/KingbaseCatalog.java","lineNumber":158,"sourceCode":"     * Override the databaseExists method because SELECT current_database() does not support WHERE\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(getUrlFromDatabaseName(databaseName), getListDatabaseSql());\n        } catch (SeaTunnelRuntimeException e) {\n            if (e.getSeaTunnelErrorCode().getCode().equals(UNSUPPORTED_METHOD.getCode())) {\n                log.warn(\n                        \"The catalog: {} is not supported the getListDatabaseSql for databaseExists\",\n                        this.catalogName);\n                return listDatabases().contains(databaseName);\n            }\n            throw e;\n        } catch (SQLException e) {\n            throw new CatalogException(\"查询数据库是否存在失败: \" + databaseName, e);\n        }\n    }\n\n    @Override\n    protected String getCreateTableSql(\n            TablePath tablePath, CatalogTable table, boolean createIndex) {\n        return new KingbaseCreateTableSqlBuilder(table, createIndex).build(tablePath);\n    }\n\n    @Override\n    protected String getDropTableSql(TablePath tablePath) {\n        return String.format(\"DROP TABLE %s\", tablePath.getSchemaAndTableName(\"\\\"\"));\n    }\n\n    @Override\n    protected String getListTableSql(String databaseName) {\n        return \"SELECT SCHEMANAME ,TABLENAME FROM SYS_TABLES\";\n    }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/kingbase/KingbaseCatalog.java#L140-L176","documentation":"KingbaseCatalog.databaseExists wraps any SQLException from the database-existence query into CatalogException(\"查询数据库是否存在失败: <databaseName>\") (\"Failed to check whether database exists\"). The concrete JDBC error is the chained cause.","triggerScenarios":"Calling databaseExists(name) (directly or via framework pre-checks) when the SQL query against the Kingbase server throws SQLException: server unreachable, wrong credentials, invalid database name characters, or the existence-check SQL is unsupported by the Kingbase version.","commonSituations":"Kingbase (人大金仓) server down or wrong port; user lacking privileges to query system databases; database name with special characters breaking the query; Kingbase version whose system catalog differs from the assumed SQL.","solutions":["Inspect the chained cause (getCause) for the underlying SQLException","Verify connectivity/credentials to the Kingbase server with a standalone JDBC client","Confirm the database name is valid and properly escaped","Check the Kingbase version supports the SQL used by getListDatabaseSql / existence query","Grant the catalog user permission to read system catalogs (e.g. pg_database equivalents)"],"exampleFix":"// before\nboolean exists = catalog.databaseExists(dbName); // CatalogException with Chinese msg\n// after\ntry {\n    boolean exists = catalog.databaseExists(dbName);\n} catch (CatalogException e) {\n    LOG.error(\"databaseExists {} failed: {}\", dbName, e.getCause());\n    throw e;\n}","handlingStrategy":"try-catch","validationCode":"try (Connection c = DriverManager.getConnection(kingbaseUrl, user, pass)) {\n    if (!c.isValid(5)) throw new IllegalStateException(\"Kingbase connection invalid\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    boolean exists = catalog.databaseExists(dbName);\n} catch (CatalogException e) {\n    LOG.error(\"Kingbase databaseExists({}) failed: {}\", dbName, e.getCause(), e);\n    throw e;\n}","preventionTips":["Inspect getCause() — the top message is a localized generic string","Verify Kingbase connectivity and credentials before catalog calls","Grant the catalog user read access to system catalogs","Escape/validate database names with special characters"],"tags":["jdbc","kingbase","sql","catalog"],"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"}