jd-opensource/joyagent-jdgenie · error · CatalogException
Failed getting table
Error message
Failed getting table %s
What it means
AbstractJdbcCatalog.getTableColumns catches any Exception while reading column metadata via DatabaseMetaData and rethrows it as CatalogException('Failed getting table %s'). It means the table's column metadata could not be fetched over JDBC.
Solutions
- Read the wrapped cause to get the underlying driver error.
- Verify the table exists: run listTables on the schema and match the exact name/casing.
- Check that the connection is valid and the user has metadata read privileges.
- Pass the correct schema argument alongside tablePath.
Example fix
// before
} catch (Exception e) {
throw new CatalogException(String.format("Failed getting table %s", tablePath), e);
}
// after
} catch (Exception e) {
throw new CatalogException(String.format("Failed getting columns for table %s (schema=%s): %s",
tablePath, schema, e.getMessage()), e);
} Defensive patterns
Strategy: validation
Validate before calling
boolean exists = catalog.listTables(conn, schema).stream()
.anyMatch(t -> t.getName().equalsIgnoreCase(tableName));
if (!exists) {
throw new IllegalArgumentException("Table " + tableName + " not found in schema " + schema);
} Try / catch
try {
return catalog.getTableColumns(conn, tablePath, schema);
} catch (CatalogException e) {
if (e.getCause() != null) log.warn("getColumn cause", e.getCause());
return List.of(); // or rethrow after verifying table existence
} Prevention
- Verify table existence/casing with listTables before getTableColumns.
- Pass the exact schema alongside tablePath.
- Check DB user privileges for column metadata.
- Keep driver and server versions compatible.
When it happens
Trigger: getTableColumns called with a tablePath/table that doesn't exist, an inaccessible schema, a closed connection, or a driver whose column-metadata ResultSet lacks expected columns like NULLABLE.
Common situations: Typo or wrong case in the table name; table dropped or renamed; schema-qualified path mismatch; user lacks metadata privileges; driver/version incompatibility.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Failed listing database in catalog
- Could not find any jdbc dialect factory that can handled
- Could not find any jdbc dialect factories that implement
- Multiple jdbc dialect factories can handle
- Could not load service provider for Catalog factory.
AI-assisted analysis of jd-opensource/joyagent-jdgenie@2417e0b8b6 (2026-09-08).
Data as JSON: /api/errors/7b74d4176636c4d9.
Report an issue: GitHub.
Appendix: source
Thrown at genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/AbstractJdbcCatalog.java:70
String name = rs.getString("COLUMN_NAME");
int intDataType = rs.getInt("DATA_TYPE");
JDBCType jdbcType = JDBCType.valueOf(intDataType);
String dataType = typeConvert(jdbcType);
TableColumn column = TableColumn.builder().name(name)
.columnLength(rs.getInt("COLUMN_SIZE"))
.comment(rs.getString("REMARKS"))
.dataType(dataType)
.originDataType(jdbcType.name())
.position(rs.getInt("ORDINAL_POSITION"))
.defaultValue(rs.getObject("COLUMN_DEF"))
.nullable(DatabaseMetaData.columnNoNulls != rs.getInt("NULLABLE")).build();
columnList.add(column);
}
return columnList;
} catch (Exception e) {
throw new CatalogException(
String.format("Failed getting table %s", tablePath), e);
}
}
public static String typeConvert(JDBCType jdbcType){
return switch (jdbcType) {
case DATE, TIME, TIMESTAMP -> StandardColumnType.DATE.name();
case TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL ->
StandardColumnType.DECIMAL.name();
default -> StandardColumnType.VARCHAR.name();
};
}
}
View on GitHub (pinned to 2417e0b8b6)