Oh, write database encounter this problem, the force is about to rip off
The reason for the exception is: Parameter You need your sql statements to different parameters, I will give you a look at the source code of Kazakhstan
//整个sql
String sql = "insert into user";
sql+=" (username,PASSWORD,gender,email,telephone,introduce,activeCode,state,role,registTime)";
sql+="values(?,?,?,?,?,?,?,?,?,?)";
//整个参数
List<Object> list = new ArrayList<>();
list.add(user.getUsername());
list.add(user.getPassword());
list.add(user.getGender());
list.add(user.getEmail());
list.add(user.getTelephone());
list.add(user.getIntroduce());
list.add(user.getActiveCode());
list.add(user.getState());
list.add(user.getRole());
list.add(user.getRegistTime());
//执行sql
qr.update(sql,list);//bug的一行
In the end there was what problem do: issue a statement in the last, what went wrong? Think about it, list is a list, if you want to pass sql in one by one alternative, or at least an array ah, then how to improve, use the toArray method list