{"record":{"id":"bbe634aefe9df2d6","repo":"apache/shardingsphere","slug":"21-bbe634","errorCode":"21","errorMessage":"Can not find column label '%s'.","messagePattern":"Can not find column label '(.+?)'\\.","errorType":"exception","errorClass":"ColumnLabelNotFoundException","httpStatus":null,"severity":"error","filePath":"jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/DatabaseMetaDataResultSet.java","lineNumber":378,"sourceCode":"    }\n    \n    @Override\n    public Object getObject(final int columnIndex) throws SQLException {\n        checkClosed();\n        checkColumnIndex(columnIndex);\n        return currentDatabaseMetaDataObject.getObject(columnIndex);\n    }\n    \n    @Override\n    public Object getObject(final String columnLabel) throws SQLException {\n        return getObject(findColumn(columnLabel));\n    }\n    \n    @Override\n    public int findColumn(final String columnLabel) throws SQLException {\n        checkClosed();\n        if (!columnLabelIndexMap.containsKey(columnLabel)) {\n            throw new ColumnLabelNotFoundException(columnLabel).toSQLException();\n        }\n        return columnLabelIndexMap.get(columnLabel);\n    }\n    \n    @Override\n    public int getType() throws SQLException {\n        checkClosed();\n        return type;\n    }\n    \n    @Override\n    public int getConcurrency() throws SQLException {\n        checkClosed();\n        return concurrency;\n    }\n    \n    @Override\n    public void setFetchDirection(final int direction) throws SQLException {","sourceCodeStart":360,"sourceCodeEnd":396,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/resultset/DatabaseMetaDataResultSet.java#L360-L396","documentation":"ColumnLabelNotFoundException (SQLState/error code 21 family) thrown by DatabaseMetaDataResultSet.findColumn when the requested column label is not a key in columnLabelIndexMap. This metadata ResultSet is backed by in-memory rows produced by ShardingSphere's DatabaseMetaData implementation, so only the exact labels it defines are resolvable.","triggerScenarios":"Calling getString/findColumn(String) on a ResultSet returned by DatabaseMetaData methods (getTables, getColumns, getIndexInfo, ...) with a label that does not exist for that metadata result set — e.g. asking for 'TABLE_NAME' on a result set that does not expose it, or a case-sensitive mismatch.","commonSituations":"Framework/schema-tooling code assuming a specific metadata column exists across drivers; porting tools written for another DB's metadata layout; typos or wrong-case labels; reading the wrong metadata method's result set.","solutions":["Inspect the result set's metadata (ResultSetMetaData.getColumnLabel) at runtime and use the exact labels present.","Read columns by index instead of label for metadata result sets.","Check the JDBC/DatabaseMetaData spec for which columns the specific metadata method returns, and fix the label name."],"exampleFix":"// before\nrs = meta.getTables(null, null, \"%\", null);\nString db = rs.getString(\"DATABASE_NAME\"); // label not in getTables result\n// after\nString db = rs.getString(\"TABLE_CAT\"); // spec-defined label","handlingStrategy":"validation","validationCode":"int idx = -1; try { idx = rs.findColumn(\"TABLE_NAME\"); } catch (SQLException ok) { /* fall back by spec order */ }","typeGuard":null,"tryCatchPattern":"catch (SQLException ex) { // ColumnLabelNotFoundException: enumerate available labels\n for (int i=1;i<=rs.getMetaData().getColumnCount();i++) log(rs.getMetaData().getColumnLabel(i)); }","preventionTips":["Use spec-defined labels for each DatabaseMetaData method","Prefer positional access on metadata result sets","Verify label existence with findColumn before getString(String)"],"tags":["jdbc","metadata","resultset","column-label"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}