{"record":{"id":"768bf1f77c8d2d25","repo":"jd-opensource/joyagent-jdgenie","slug":"s-768bf1","errorCode":null,"errorMessage":"获取表字段信息失败 %s","messagePattern":"获取表字段信息失败 (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/h2/H2SqlCatalog.java","lineNumber":84,"sourceCode":"            List<TableColumn> columnList = new ArrayList<>();\n            while (rs.next()) {\n                String columnName = rs.getString(\"column_name\");\n                String jdbcDataType = rs.getString(\"data_type\").toUpperCase();\n                String dataType = typeConvertMysql(jdbcDataType);\n                String comment = rs.getString(\"remarks\");\n                TableColumn column = TableColumn.builder().name(columnName)\n                        .comment(comment)\n                        .dataType(dataType)\n                        .originDataType(jdbcDataType)\n                        .nullable(rs.getBoolean(\"is_nullable\"))\n                        .position(i++)\n                        .build();\n                columnList.add(column);\n            }\n            return columnList;\n\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\"获取表字段信息失败 %s\", tablePath), e);\n        }\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":89,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/h2/H2SqlCatalog.java#L66-L89","documentation":"H2SqlCatalog.getTableColumns wraps any exception while reading column metadata for a table into CatalogException '获取表字段信息失败 <tablePath>'. The cause holds the underlying SQL error. It indicates the column metadata query for the given table could not be executed or read.","triggerScenarios":"Calling getTableColumns(tablePath) when the table does not exist in the H2 schema, the connection is broken, or the metadata query throws (SQLException or runtime error).","commonSituations":"Typo in table path, querying a table that was just dropped from the in-memory H2 DB, wrong schema prefix, or insufficient privileges on information_schema.","solutions":["Verify the table exists (listTables) and the tablePath matches schema.table exactly.","Check H2 identifier casing (uppercase by default).","Inspect the wrapped cause for the precise SQL error.","Recreate/reopen the H2 database if it was dropped or closed."],"exampleFix":"// before\ncatalog.getTableColumns(\"public.users\"); // table actually in schema PUBLIC\n// after\ncatalog.getTableColumns(\"PUBLIC.USERS\");","handlingStrategy":"try-catch","validationCode":"// Java: check the table exists first\nList<SimpleTable> tables = h2Catalog.listTables(schema);\nboolean exists = tables.stream().anyMatch(t -> t.getTableName().equalsIgnoreCase(tableName));\nif (!exists) throw new IllegalStateException(\"table not found: \" + tablePath);","typeGuard":null,"tryCatchPattern":"try {\n    List<Column> cols = h2Catalog.getTableColumns(tablePath);\n} catch (CatalogException e) {\n    log.error(\"getTableColumns failed for {}: {}\", tablePath, e.getCause().getMessage(), e);\n}","preventionTips":["Confirm the table exists with listTables before fetching columns.","Pass fully qualified schema.table paths with correct casing.","Watch for in-memory H2 data loss on restart.","Check information_schema privileges."],"tags":["jdbc","h2","catalog","metadata"],"backgroundTag":"database-query-failed","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}