{"record":{"id":"32a29f41ffd69971","repo":"apache/seatunnel","slug":"failed-listing-database-in-catalog-this-catalogna","errorCode":null,"errorMessage":"Failed listing database in catalog {this.catalogName}","messagePattern":"Failed listing database in catalog (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/AbstractJdbcCatalog.java","lineNumber":356,"sourceCode":"\n    protected String getListDatabaseSql() {\n        throw new UnsupportedOperationException();\n    }\n\n    protected String getListViewSql(String databaseName) {\n        throw new UnsupportedOperationException();\n    }\n\n    protected String getDatabaseWithConditionSql(String databaseName) {\n        throw CommonError.unsupportedMethod(this.catalogName, \"getDatabaseWithConditionSql\");\n    }\n\n    @Override\n    public List<String> listDatabases() throws CatalogException {\n        try {\n            return queryString(defaultUrl, getListDatabaseSql(), rs -> rs.getString(1));\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\"Failed listing database in catalog %s\", this.catalogName), e);\n        }\n    }\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            }","sourceCodeStart":338,"sourceCodeEnd":374,"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#L338-L374","documentation":"AbstractJdbcCatalog.listDatabases() executes the dialect's list-databases SQL via queryString() and wraps any failure into CatalogException('Failed listing database in catalog <name>'). It is thrown when catalog metadata discovery cannot query the server for database names.","triggerScenarios":"queryString(defaultUrl, getListDatabaseSql(), rs -> rs.getString(1)) throws any Exception — connection failure or the catalog's listDatabases SQL fails/returns unexpected results; also reachable via databaseExists().","commonSituations":"DB server unreachable at defaultUrl (down, firewall, wrong port); catalog user lacks permission to list databases/schemas; dialect's getListDatabaseSql unsupported on old server versions; TLS/auth failure on metadata connection.","solutions":["Check connectivity to defaultUrl (host/port/credentials) with a standalone client.","Grant the catalog user permission to list databases (e.g. SHOW DATABASES / access to system catalogs).","Inspect the wrapped cause; if it's SQL syntax, the dialect's list-database SQL doesn't fit your server version — upgrade connector or use a matching dialect.","Verify driver and TLS configuration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try (Connection c = DriverManager.getConnection(defaultUrl, user, pass); ResultSet rs = c.createStatement().executeQuery(\"SHOW DATABASES\")) { while (rs.next()) rs.getString(1); }","typeGuard":null,"tryCatchPattern":"catch (CatalogException e) { log.error(\"listDatabases failed: {}\", e.getMessage(), e.getCause()); /* check connectivity/permissions on defaultUrl */ }","preventionTips":["Verify defaultUrl connectivity before catalog operations","Grant list-databases privileges to the catalog user","Match connector dialect to server version and driver"],"tags":["jdbc","catalog","list-databases","metadata"],"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"}