报错信息:StatementCallback; bad SQL grammar [DELETE from graphedges where target = node20213246184944850]; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'node20213246184944850' in 'where clause'
问题代码:`
public int delete_whichTable_whichAttribute_whichParam(String tableName, String attribute, String param) {
return jdbcTemplate.update("DELETE from "+tableName+" where "+attribute+" = "+param);
}`
问题原因:如果直接+param,那么转换为sql语句将没有引号,需要改正为以下代码:
@Override
public int delete_whichTable_whichAttribute_whichParam(String tableName, String attribute, String param) {
return jdbcTemplate.update("DELETE from "+tableName+" where "+attribute+" = ?",param);
}
修改:" = “+param);改为” = ?",param);