我得到这个错误 - “java.sql.SQLException:参数索引超出范围(6>参数个数,即5)”。
我试图更新有关我的用户的信息 - 通过GWT和MySql - 当然
public boolean changePersonInfo(Person person) throws IllegalArgumentException {
try {
PreparedStatement updatePerson = connection.prepareStatement("UPDATE users SET " + "adgangskode = ?, "
+ "email = ?, " + "alder = ?, " + "tlfnr = ?, " + "WHERE id = ?");
updatePerson.setString(1, person.getPassword());
updatePerson.setString(2, person.getEmail());
updatePerson.setString(3, person.getAge() + "");
updatePerson.setString(4, person.getPhonenumber());
updatePerson.setInt(5, person.getId());
int rowsAffected = updatePerson.executeUpdate();
if (rowsAffected == 1) {
return true;
}
} catch (SQLException sqlException) {
sqlException.printStackTrace();
}
return false;
还有这个函数应该与我的clickhandler - 和RpcServiceImpl
交谈class SettingsClickhandler implements ClickHandler{
@Override
public void onClick(ClickEvent event) {
currentPerson.setPassword(userView.getSettingsView().getPassBoxChange().getText());
currentPerson.setEmail(userView.getSettingsView().getEmailBoxChange().getText());
currentPerson.setAge(Integer.valueOf(userView.getSettingsView().getAgeChangeBox().getText()));
currentPerson.setPhonenumber(userView.getSettingsView().getTlfChangeBox().getText());
// The RPC call which through the server updates the user info in the users table in the database
Service.changePersonInfo(currentPerson, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
}
/*
* Confirmation if the info was updated
*/
@Override
public void onSuccess(Boolean isUpdated) {
if (isUpdated) {
content.getUserView().getSettingsView();
userView.getSettingsView().clearTextBoxFields();
Window.alert("Aendring lykkes");
}else{
userView.getSettingsView();
Window.alert("Aendring Mislykkes");
}