{"record":{"id":"934fcb40159dfa6a","repo":"MyCATApache/Mycat-Server","slug":"can-t-find-hint-schema-hintsqlvalue-934fcb","errorCode":null,"errorMessage":"\"can't find hint schema:\" + hintSQLValue","messagePattern":"\"can't find hint schema:\" \\+ hintSQLValue","errorType":"exception","errorClass":"SQLNonTransientException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/handler/HintSchemaHandler.java","lineNumber":55,"sourceCode":"\t * @param charset\n\t * @param info\n\t * @param cachePool\n\t * @param hintSQLValue\n\t * @return\n\t * @throws SQLNonTransientException\n\t */\n\t@Override\n\tpublic RouteResultset route(SystemConfig sysConfig, SchemaConfig schema,\n\t\t\tint sqlType, String realSQL, String charset, ServerConnection sc,\n\t\t\tLayerCachePool cachePool, String hintSQLValue,int hintSqlType, Map hintMap)\n\t\t\tthrows SQLNonTransientException {\n\t    SchemaConfig tempSchema = MycatServer.getInstance().getConfig().getSchemas().get(hintSQLValue);\n\t\tif (tempSchema != null) {\n\t\t\treturn routeStrategy.route(sysConfig, tempSchema, sqlType, realSQL, charset, sc, cachePool);\n\t\t} else {\n\t\t\tString msg = \"can't find hint schema:\" + hintSQLValue;\n\t\t\tLOGGER.warn(msg);\n\t\t\tthrow new SQLNonTransientException(msg);\n\t\t}\n\t}\n}\n","sourceCodeStart":37,"sourceCodeEnd":59,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/handler/HintSchemaHandler.java#L37-L59","documentation":"The /*schema=...*/ hint overrides which logical schema a statement is routed against. HintSchemaHandler looks up hintSQLValue in the config's schemas map; if no schema of that name is configured, routing cannot proceed and a SQLNonTransientException is thrown.","triggerScenarios":"Sending `/* schema=shopdb */ SELECT ...` (or HintManager.useSchema(\"shopdb\")) where 'shopdb' is not a <schema name=\"...\"> in Mycat's schema.xml, or the schema was dropped/renamed on reload.","commonSituations":"Typo or wrong-case schema name in the hint; environment drift (hint hard-coded for a schema that exists only in another environment); config reloaded without the schema.","solutions":["Correct the hint value to match an existing <schema name=\"...\"> in schema.xml","Verify the schema exists with show @@schema or the config dump, then retry","Remove the hint and rely on the connection's default schema (USE statement / connection URL)"],"exampleFix":"-- before\n/*schema=shop_db*/ SELECT * FROM orders LIMIT 1;\n-- after (schema.xml defines <schema name=\"shopdb\">)\n/*schema=shopdb*/ SELECT * FROM orders LIMIT 1;","handlingStrategy":"validation","validationCode":"if (!mycatConfig.getSchemas().containsKey(schemaHint)) {\n    throw new IllegalArgumentException(\"unknown schema hint: \" + schemaHint);\n}","typeGuard":null,"tryCatchPattern":"try { queryWithSchemaHint(name, sql); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith(\"can't find hint schema\")) { fallBackToDefaultSchema(sql); } else throw e; }","preventionTips":["Match hint schema names exactly against schema.xml entries","Keep schema names identical across dev/staging/prod","Verify schema existence after config reloads","Prefer USE <schema> over schema hints where possible"],"tags":["mysql","routing","hint","schema"],"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"}