{"record":{"id":"f64ea96c850aac76","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-table-define-of-in-schema","errorCode":null,"errorMessage":"can't find table define of  in schema:","messagePattern":"can't find table define of  in schema:","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/parser/druid/impl/DruidLockTableParser.java","lineNumber":33,"sourceCode":"import io.mycat.route.parser.druid.MycatSchemaStatVisitor;\nimport io.mycat.server.parser.ServerParse;\nimport io.mycat.util.SplitUtil;\n\n/**\n * lock tables [table] [write|read]语句解析器\n * @author songdabin\n */\npublic class DruidLockTableParser extends DefaultDruidParser implements DruidParser {\n\t@Override\n\tpublic void statementParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt)\n\t\t\tthrows SQLNonTransientException {\n\t\tMySqlLockTableStatement lockTableStat = (MySqlLockTableStatement)stmt;\n\t\tString table = lockTableStat.getItems().get(0).getTableSource().toString().toUpperCase();\n\t\tTableConfig tableConfig = schema.getTables().get(table);\n\t\tif (tableConfig == null) {\n\t\t\tString msg = \"can't find table define of \" + table + \" in schema:\" + schema.getName();\n\t\t\tLOGGER.warn(msg);\n\t\t\tthrow new SQLNonTransientException(msg);\n\t\t}\n\t\tLockType lockType = lockTableStat.getItems().get(0).getLockType();\n\t\tif (LockType.WRITE != lockType && LockType.READ != lockType) {\n\t\t\tString msg = \"lock type must be write or read\";\n\t\t\tLOGGER.warn(msg);\n\t\t\tthrow new SQLNonTransientException(msg);\n\t\t}\n\t\tList<String> dataNodes = tableConfig.getDataNodes();\n\t\tRouteResultsetNode[] nodes = new RouteResultsetNode[dataNodes.size()];\n\t\tfor (int i = 0; i < dataNodes.size(); i ++) {\n\t\t\tnodes[i] = new RouteResultsetNode(dataNodes.get(i), ServerParse.LOCK, stmt.toString());\n\t\t}\n\t\trrs.setNodes(nodes);\n\t\trrs.setFinishedRoute(true);\n\t}\n\t\n\t@Override\n\tpublic void visitorParse(SchemaConfig schema, RouteResultset rrs, SQLStatement stmt, MycatSchemaStatVisitor visitor)","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/parser/druid/impl/DruidLockTableParser.java#L15-L51","documentation":"DruidLockTableParser.statementParse resolves the first table of a LOCK TABLES statement against schema.getTables(). If no TableConfig exists for that (upper-cased) table name in the current schema, it throws SQLNonTransientException reporting the missing table and schema name.","triggerScenarios":"LOCK TABLES statement whose first table is not defined in the MyCat schema.xml for the connected schema (no <table> entry, wrong case, or table only exists physically in MySQL).","commonSituations":"Locking a global/temp table not declared in schema.xml; case-sensitivity mismatch (MyCat stores table names upper-cased); connecting to the wrong logical schema; table added to MySQL after MyCat config was written.","solutions":["Add the missing <table> definition for the table in schema.xml and reload","Verify you connected to the intended MyCat logical schema","Match the table name case with the schema.xml definition (MyCat upper-cases lookups)","Avoid LOCK TABLES on non-configured tables; use application-level locking instead"],"exampleFix":"// before (schema.xml has no entry)\nLOCK TABLES my_table WRITE;\n// after\n<table name=\"MY_TABLE\" dataNode=\"dn1\"/> added to schema.xml, then retry LOCK TABLES MY_TABLE WRITE;","handlingStrategy":"validation","validationCode":"TableConfig tc = schema.getTables().get(table.toUpperCase()); if (tc == null) throw new IllegalArgumentException(\"table not in MyCat schema: \" + table);","typeGuard":null,"tryCatchPattern":"try { lockTables(sql); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"can't find table define of\")) { alertMissingSchemaEntry(extractTable(e)); } else throw e; }","preventionTips":["Ensure every table used by the app has a schema.xml <table> entry","Keep table name casing consistent with schema.xml","Run a startup check comparing MySQL tables against MyCat schema config","Avoid LOCK TABLES through proxy layers; prefer transactions"],"tags":["sql","lock","schema","configuration"],"backgroundTag":"resource-not-found","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"}