本文主要是介绍报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ”meltFlowRate’ (id) values (21)’ at line 1
原因:使用mybatis动态表名的时候,表名用该用反引号括起来,我用了单引号;
以下是错误的实现:
String tableName ="meltFlowRate";int sampleId = 21;Map<String, Object> map = new HashMap<String, Object>();map.put("tableName", "'" + tableName + "'");map.put("sampleId", sampleId);int res = common.insertSample(map);
以下是正确的实现:
String tableName ="meltFlowRate";int sampleId = 21;Map<String, Object> map = new HashMap<String, Object>();map.put("tableName", "`" + tableName + "`");map.put("sampleId", sampleId);int res = common.insertSample(map);
这篇关于报错:You have an error in your SQL syntax; check the manual that corresponds to your MySQL的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!