{"record":{"id":"7b74d4176636c4d9","repo":"jd-opensource/joyagent-jdgenie","slug":"failed-getting-table-s","errorCode":null,"errorMessage":"Failed getting table %s","messagePattern":"Failed getting table (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/AbstractJdbcCatalog.java","lineNumber":70,"sourceCode":"                String name = rs.getString(\"COLUMN_NAME\");\n                int intDataType = rs.getInt(\"DATA_TYPE\");\n                JDBCType jdbcType = JDBCType.valueOf(intDataType);\n                String dataType = typeConvert(jdbcType);\n\n                TableColumn column = TableColumn.builder().name(name)\n                        .columnLength(rs.getInt(\"COLUMN_SIZE\"))\n                        .comment(rs.getString(\"REMARKS\"))\n                        .dataType(dataType)\n                        .originDataType(jdbcType.name())\n                        .position(rs.getInt(\"ORDINAL_POSITION\"))\n                        .defaultValue(rs.getObject(\"COLUMN_DEF\"))\n                        .nullable(DatabaseMetaData.columnNoNulls != rs.getInt(\"NULLABLE\")).build();\n                columnList.add(column);\n            }\n            return columnList;\n\n        } catch (Exception e) {\n            throw new CatalogException(\n                    String.format(\"Failed getting table %s\", tablePath), e);\n        }\n    }\n\n    public static   String typeConvert(JDBCType jdbcType){\n        return switch (jdbcType) {\n            case DATE, TIME, TIMESTAMP -> StandardColumnType.DATE.name();\n            case TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, NUMERIC, DECIMAL ->\n                    StandardColumnType.DECIMAL.name();\n            default -> StandardColumnType.VARCHAR.name();\n        };\n    }\n\n}\n","sourceCodeStart":52,"sourceCodeEnd":85,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/data/jdbc/catalog/AbstractJdbcCatalog.java#L52-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typo or wrong case in the table name; table dropped or renamed; schema-qualified path mismatch; user lacks metadata privileges; driver/version incompatibility.","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."],"exampleFix":"// before\n} catch (Exception e) {\n    throw new CatalogException(String.format(\"Failed getting table %s\", tablePath), e);\n}\n// after\n} catch (Exception e) {\n    throw new CatalogException(String.format(\"Failed getting columns for table %s (schema=%s): %s\",\n        tablePath, schema, e.getMessage()), e);\n}","handlingStrategy":"validation","validationCode":"boolean exists = catalog.listTables(conn, schema).stream()\n    .anyMatch(t -> t.getName().equalsIgnoreCase(tableName));\nif (!exists) {\n    throw new IllegalArgumentException(\"Table \" + tableName + \" not found in schema \" + schema);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return catalog.getTableColumns(conn, tablePath, schema);\n} catch (CatalogException e) {\n    if (e.getCause() != null) log.warn(\"getColumn cause\", e.getCause());\n    return List.of(); // or rethrow after verifying table existence\n}","preventionTips":["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."],"tags":["java","jdbc","catalog","database"],"backgroundTag":"resource-not-found","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"}