title: Update sql statement in servlet not in servlet
body: <p>I am trying to allow the user to change the password if he enters the right username. The username is drawn from the database and compared to the username the user enter in a form. My problem is after the validation is done the UPDATE statement is not producing any result. Can someone help me out please?</p>
  
  <pre><code>   String un = request.getParameter("username");
      String psw = request.getParameter("password");
      String cPsw = request.getParameter("cpassword");
      Connection con = ConnectionHelper.getConnection();
  
      try {
          ResultSet rs = userList(con);
          if (rs.next()) {
  
              String n = rs.getString("username");
  
              if (n.equals(un)) {
                  out.print("Password match");
                  String updateQuery = "UPDATE RegisteredUserInfo SET password ='"
                          + cPsw + "'WHERE username ='" + un + "'";
  
                  PreparedStatement ps1 = con.prepareStatement(updateQuery);
                  ps1.executeQuery();
  
                  ServletContext context = getServletContext();
                  RequestDispatcher rd = context
                          .getRequestDispatcher("/Welcome.jsp");
                  rd.forward(request, response);
              }
          }
  
      } catch (SQLException sx) {
          out.println();
      }
  }
  
  public ResultSet userList(Connection con) throws SQLException {
      PreparedStatement ps;
      ResultSet rs;
      String matchingUname = "SELECT username FROM RegisteredUserInfo";
      ps = con.prepareStatement(matchingUname);
      rs = ps.executeQuery();
      return rs;`
  </code></pre>