java.sql.SQLException: No value specifiedfor parameter 2
代码:
publicboolean addPerson(Person p) {
boolean is = false;
String sql = "insert intostudent(name,psw) values(?,?)";
List<String> argList = new ArrayList<String>();
// argList.add(String.valueOf(p.getId()));
argList.add(p.getName());
argList.add(p.getPassword());
int i = jdbcTemplate.update(sql, argList);
if(i>0){
is = true;
}
return is;
}
解决办法: int i = jdbcTemplate.update(sql, argList.toArray());
转载于:https://blog.51cto.com/qihoushangshu/1437098