{"record":{"id":"5dabde18ce63b8a2","repo":"baomidou/mybatis-plus","slug":"s-5dabde","errorCode":null,"errorMessage":"读取[%s]字段出错!","messagePattern":"读取\\[(.+?)\\]字段出错!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/querys/DbQueryDecorator.java","lineNumber":243,"sourceCode":"\n        private final IDbQuery dbQuery;\n\n        @Getter\n        private final ResultSet resultSet;\n\n        private final DbType dbType;\n\n        ResultSetWrapper(ResultSet resultSet, IDbQuery dbQuery, DbType dbType) {\n            this.resultSet = resultSet;\n            this.dbQuery = dbQuery;\n            this.dbType = dbType;\n        }\n\n        public String getStringResult(String columnLabel) {\n            try {\n                return resultSet.getString(columnLabel);\n            } catch (SQLException sqlException) {\n                throw new RuntimeException(String.format(\"读取[%s]字段出错!\", columnLabel), sqlException);\n            }\n        }\n\n        /**\n         * @return 获取字段注释\n         */\n        public String getFiledComment() {\n            return getComment(dbQuery.fieldComment());\n        }\n\n        /**\n         * 获取格式化注释\n         *\n         * @param columnLabel 字段列\n         * @return 注释\n         */\n        private String getComment(String columnLabel) {\n            return StringUtils.isNotBlank(columnLabel) ? formatComment(getStringResult(columnLabel)) : StringPool.EMPTY;","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/baomidou/mybatis-plus/blob/bf67d907478c724120bf76292da54abf9e73c2b3/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/querys/DbQueryDecorator.java#L225-L261","documentation":"ResultSetWrapper.getStringResult wraps the SQLException thrown by ResultSet.getString(columnLabel) for a single metadata column (table name, remarks, key name, etc.). It means the configured IDbQuery asked the ResultSet for a column label the executed metadata query did not produce.","triggerScenarios":"Any DbQueryDecorator metadata read (tableName(), tableComment(), fieldName()...) where the driver fails to resolve columnLabel — mismatched DbType (e.g. DbType set to MYSQL against a PostgreSQL URL), custom IDbQuery tablesSql/columnsSql not matching fieldNames(), or driver metadata column renames.","commonSituations":"Setting dbQuery/DbType explicitly to a wrong database type so the adapter's SQL runs but returns different column names; using a custom IDbQuery copied from another database's adapter without adjusting the column labels; older JDBC drivers returning lowercase/uppercase labels.","solutions":["Read the wrapped SQLException to see the missing column label and the SQL that ran; the mismatch is usually obvious.","Do not force dbQuery manually — pass the correct JDBC URL and let DataSourceConfig infer the DbType, so the matching adapter is used.","If a custom IDbQuery is used, verify every column label in tableName()/tableComment()/fieldNames() is selected by your tablesSql()/columnsSql().","Upgrade the JDBC driver to one whose metadata column labels match what the bundled adapter expects."],"exampleFix":"// before\nnew DataSourceConfig.Builder(url, user, pass).dbQuery(new MySqlQuery()); // url is postgres\n\n// after\nnew DataSourceConfig.Builder(url, user, pass); // DbType auto-detected from URL -> PostgreSqlQuery","handlingStrategy":"validation","validationCode":"// Before generating: verify DbType inferred from URL matches the adapter you intend\nDataSourceConfig ds = new DataSourceConfig.Builder(url, user, pass).build();\n// ensure you did NOT force a mismatched dbQuery; rely on auto-detection:\n// ds.getDbQuery() must be an instance of the adapter for your real database","typeGuard":null,"tryCatchPattern":"try {\n    generator.generate();\n} catch (RuntimeException e) {\n    Throwable root = e;\n    while (root.getCause() != null) root = root.getCause();\n    if (root instanceof SQLException) log.error(\"metadata column mismatch: {}\", root.getMessage());\n}","preventionTips":["Never hardcode dbQuery for a different database than the JDBC URL.","Smoke-test the generator against a scratch schema whenever the DB or driver is upgraded.","For custom IDbQuery, keep tablesSql/columnsSql and the field-name accessors in one reviewed file."],"tags":["mybatis-plus","code-generator","jdbc","metadata","configuration"],"backgroundTag":null,"analyzedSha":"bf67d907478c724120bf76292da54abf9e73c2b3","analyzedAt":"2026-08-14T15:17:09.543Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}