jd-opensource/joyagent-jdgenie · error · CatalogException
获取表字段信息失败
Error message
获取表字段信息失败 %s
What it means
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.
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.
Example fix
// before
catalog.getTableColumns("public.users"); // table actually in schema PUBLIC
// after
catalog.getTableColumns("PUBLIC.USERS"); Defensive patterns
Strategy: try-catch
Validate before calling
// Java: check the table exists first
List<SimpleTable> tables = h2Catalog.listTables(schema);
boolean exists = tables.stream().anyMatch(t -> t.getTableName().equalsIgnoreCase(tableName));
if (!exists) throw new IllegalStateException("table not found: " + tablePath); Try / catch
try {
List<Column> cols = h2Catalog.getTableColumns(tablePath);
} catch (CatalogException e) {
log.error("getTableColumns failed for {}: {}", tablePath, e.getCause().getMessage(), e);
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/768bf1f77c8d2d25.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/h2/H2SqlCatalog.java:84
List<TableColumn> columnList = new ArrayList<>();
while (rs.next()) {
String columnName = rs.getString("column_name");
String jdbcDataType = rs.getString("data_type").toUpperCase();
String dataType = typeConvertMysql(jdbcDataType);
String comment = rs.getString("remarks");
TableColumn column = TableColumn.builder().name(columnName)
.comment(comment)
.dataType(dataType)
.originDataType(jdbcDataType)
.nullable(rs.getBoolean("is_nullable"))
.position(i++)
.build();
columnList.add(column);
}
return columnList;
} catch (Exception e) {
throw new CatalogException(
String.format("获取表字段信息失败 %s", tablePath), e);
}
}
}
View on GitHub (pinned to 2417e0b8b6)