{"record":{"id":"65a9c6973d5a2166","repo":"MyCATApache/Mycat-Server","slug":"schema-name-didn-t-config-tables-so-you-must-se","errorCode":null,"errorMessage":"schema ${name} didn't config tables,so you must set dataNode property!","messagePattern":"schema (.+?) didn't config tables,so you must set dataNode property!","errorType":"exception","errorClass":"ConfigException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java","lineNumber":177,"sourceCode":"            if (dataNode != null && !dataNode.isEmpty()) {\n                List<String> dataNodeLst = new ArrayList<String>(1);\n                dataNodeLst.add(dataNode);\n                checkDataNodeExists(dataNodeLst);\n                String dataHost = dataNodes.get(dataNode).getDataHost();\n                defaultDbType = dataHosts.get(dataHost).getDbType();\n            } else {\n                dataNode = null;\n            }\n            //加载schema下所有tables\n            Map<String, TableConfig> tables = loadTables(schemaElement);\n            //判断schema是否重复\n            if (schemas.containsKey(name)) {\n                throw new ConfigException(\"schema \" + name + \" duplicated!\");\n            }\n\n            // 设置了table的不需要设置dataNode属性，没有设置table的必须设置dataNode属性\n            if (dataNode == null && tables.size() == 0) {\n                throw new ConfigException(\n                        \"schema \" + name + \" didn't config tables,so you must set dataNode property!\");\n            }\n\n            SchemaConfig schemaConfig = new SchemaConfig(name, dataNode,\n                    tables, sqlMaxLimit, \"true\".equalsIgnoreCase(checkSQLSchemaStr),randomDataNode);\n\n            //设定DB类型，这对之后的sql语句路由解析有帮助\n            if (defaultDbType != null) {\n                schemaConfig.setDefaultDataNodeDbType(defaultDbType);\n                if (!\"mysql\".equalsIgnoreCase(defaultDbType)) {\n                    schemaConfig.setNeedSupportMultiDBType(true);\n                }\n            }\n\n            // 判断是否有不是mysql的数据库类型，方便解析判断是否启用多数据库分页语法解析\n            for (TableConfig tableConfig : tables.values()) {\n                if (isHasMultiDbType(tableConfig)) {\n                    schemaConfig.setNeedSupportMultiDBType(true);","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/config/loader/xml/XMLSchemaLoader.java#L159-L195","documentation":"A <schema> element in schema.xml must either declare at least one <table> child or set the dataNode attribute (the default node for un-routed tables). loadSchemas throws this ConfigException when both are missing, because MyCat would have nowhere to route plain tables in that schema.","triggerScenarios":"schema.xml has <schema name=\"X\"> with no <table> children and no dataNode attribute; load() -> loadSchemas() evaluates dataNode == null && tables.size() == 0 and throws.","commonSituations":"Creating an empty placeholder schema expecting tables to be added later; removing all table entries during cleanup while also clearing dataNode; template configs omitting dataNode on non-default schemas.","solutions":["Add dataNode=\"dnN\" to the <schema> element so it has a default node.","Alternatively declare the <table> entries the schema should serve.","If the schema is intentionally empty, remove it entirely from schema.xml."],"exampleFix":"// before (schema.xml)\n<schema name=\"TESTDB2\"></schema>\n// after\n<schema name=\"TESTDB2\" dataNode=\"dn1\"></schema>","handlingStrategy":"validation","validationCode":"// Each <schema> must have tables or a dataNode\nNodeList schemas = doc.getElementsByTagName(\"schema\");\nfor (int i = 0; i < schemas.getLength(); i++) {\n    Element s = (Element) schemas.item(i);\n    boolean hasDataNode = !s.getAttribute(\"dataNode\").isEmpty();\n    boolean hasTables = s.getElementsByTagName(\"table\").getLength() > 0;\n    if (!hasDataNode && !hasTables)\n        throw new IllegalStateException(\"schema \" + s.getAttribute(\"name\") + \" needs dataNode or <table> entries\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    loader = new XMLSchemaLoader();\n} catch (ConfigException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"didn't config tables\")) {\n        LOG.error(\"Schema missing dataNode and tables: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Always set dataNode on schemas that serve plain (non-table-routed) SQL.","Do not delete all <table> children without also checking dataNode remains set.","Lint every <schema> element for dataNode-or-tables presence in CI."],"tags":["configuration","xml","missing-required-field","schema"],"backgroundTag":"missing-required-config-field","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}