Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4054672
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:36:19+00:00 2026-05-20T14:36:19+00:00

I am having problem updating my mysql in my web application.. I can’t Update

  • 0

I am having problem updating my mysql in my web application.. I can’t Update an Entry.

It successfully enters the servlet… but it doesn’t update an ENTRY, I suspect it was about my QUERY…

it was like this:

String query = "UPDATE members SET Username = ?, Password = ?, FirstName = ?, "
            + "MiddleName = ?, LastName = ?, Address = ?, Email = ? "
            + "WHERE memberId = ? AND Username = ?";

is that valid?

This is my servlet code:

public class EditMember extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    String query = "UPDATE members SET Username = ?, Password = ?, FirstName = ?, "
            + "MiddleName = ?, LastName = ?, Address = ?, Email = ? "
            + "WHERE memberId = ? AND Username = ?";

    try {
        Class.forName(Connect.DRIVER);
        con = DriverManager.getConnection(Connect.CONNECTION_STRING,
                Connect.USERNAME, Connect.PASSWORD);

        String currUserame = request.getParameter("CreateUsername");
        String currPassword = request.getParameter("CreatePassword");
        String currFirstName = request.getParameter("CurrFirstName");
        String currMiddleName = request.getParameter("currMiddleName");
        String currLastName = request.getParameter("currLastName");
        String currAddress = request.getParameter("currAddress");
        String currEmail = request.getParameter("currEmail");

        int memberId = Integer.parseInt(request.getParameter("memberId"));
        String oldPassword = request.getParameter("Password");

            stmt = con.prepareStatement(query);
            stmt.setString(1, currUserame);
            stmt.setString(2, currPassword);
            stmt.setString(3, currFirstName);
            stmt.setString(4, currMiddleName);
            stmt.setString(5, currLastName);
            stmt.setString(6, currAddress);
            stmt.setString(7, currEmail);

            stmt.setInt(8, memberId);
            stmt.setString(9, oldPassword);
            stmt.executeUpdate();

            out.println("Success");//for testing only

    } catch (Exception ex) {
        out.println("Exception");
    } finally {
        try {
            con.close();
        } catch (SQLException ex) {
            out.println("Sql Exception");
        }
        out.close();
    }
}

//HttpServlet methods were placed here

}

and this is my jsp:

<body>
    <form action="EditMember">
        <h1>Enter old Info</h1><br/>
        Enter your Id:
        <input type="text" name="memberId"><br/>
        Enter your Password:
        <input type="password" name="Password" /><br/>

        <h1>Enter New Info</h1><br/>
        User Name:
        <input type="text" name="CreateUsername" /><br/>
        Re-Enter/New Password:
        <input type="password" name="CreatePassword" /><br/>
        First Name:
        <input type="text" name="CurrFirstName"><br/>
        Middle Name:
        <input type="text" name="currMiddleName"><br/>
        Last Name:
        <input type="text" name="currLastName"><br/>
        Address:
        <input type="text" name="currAddress"><br/>
        Email Add.:
        <input type="text" name="currEmail">
        <br/>
        <input type="submit" name="Submit" id="Submit" value="Save New Info" />
    </form>
</body>

I already check each variable I used in JSP if it matched with the variable i used in my servlet… it was all the same.. So aside from the QUERY i don’t know other things that causes the problem…

please help…. thanks a lot in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:36:20+00:00Added an answer on May 20, 2026 at 2:36 pm

    You are binding the wrong variable to the last parameter on your query. You are doing stmt.setString(9, oldPassword); and it probably should be stmt.setString(9, oldUsername);.

    And btw, if memberId is a primary or unique key, then you don’t need the AND username = ? part in your WHERE clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem updating several rows of a mysql table using a
I am new to mysql and am having a problem updating my sql database
I've a little problem, with a ASPX .NET application that I'm updating. After having
We're having mysterious network problems with MySQL. Simple update query (updating single row using
Alright so I'm having a problem with updating a model. I can create a
I am trying to learn mysql and having some problem with updating/adding data to
I am having a problem updating the view in android every x seconds. To
I'm having a problem updating a row after an inline edit. My ColModel is:
I'm having a problem updating a table and im sure its pretty straight forward
I am having an update statament in my jsp. The problem is that when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.