报错: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);