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

  • Home
  • SEARCH
  • 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 8491367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:24:12+00:00 2026-06-10T22:24:12+00:00

Hi When i’m trying to update a jdbc table only first row gets updated

  • 0

Hi When i’m trying to update a jdbc table only first row gets updated below is the code for it. though i have an individual button for every row any button i clicks takes input values as first row’s.

<tr>
           <td><%=rs.getString("DBID")%></td>
           <td><input type="text" name="prev" id="prev" value="<%=rs.getString("Query_Raised")%>" border=''></td>
           <td><%=rs.getString("TR")%> </td>
           <td><%=rs.getString("Query_Answered")%></td>
           <td><%=rs.getString("TA")%></td>
           <td><input type="submit" value="Edit">
       </tr>

and for comparing i used the below(for where condition) and it is also taking only the first row value

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body><form method="post" action="Up_Query_DB.jsp">
        <table><tr><td> <input type="text" id="xyz" name="xyz" value="<%=request.getParameter("prev")%>"></td></tr>
            <tr><td><INPUT TYPE="TEXT" NAME="updat" id="updat"></td></tr>
            <tr><td><input type="submit" value="Update"></td></tr></table></form>
</body>

and the update i used is

<% try
                 {
   String sc=request.getParameter("xyz");
   String upd=request.getParameter("updat");
   ps=con.prepareStatement("Update Scope1 Set Query_Raised='"+upd+"' where Query_Raised='"+sc+"'");
   int i=ps.executeUpdate();
   if(i==1)
                 {
       String redirectURL= "View Queries.jsp";
       response.sendRedirect(redirectURL);

   }
         else{
       out.print("Erro");
         }
 }
   catch(Exception e)
                   {
    out.println("error");

   }%>

Thanks

  • 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-06-10T22:24:13+00:00Added an answer on June 10, 2026 at 10:24 pm

    1) It helps to write valid HTML
    <td><input type="submit" value="Edit"></td>
    2) Even though you have an Edit button for every row, you have no way of knowing which of the buttons was actually pressed when submitting the form – they are all the same.
    Most common way of implementing multi-row edit is to have a separate form for each row. Unless you want to be able to edit multiple rows and then submit all changes at once in which case you will need to distinguish between rows’ data – by giving your data input fields unique names.

    Later edit:
    3) updating table rows based on value that you intend to change is bad idea for various reasons, one of them is that your query may update the rows that you never knew even existed.

    <tr>
    <form ... >
    <td> <input type="hidden" name="recordID" value="%dynamicRecordIDFromYourDB%" /> </td>
    ...
    <td> <input type="text" name="data" value="%updatableDataFromYourDB" />
    <td> <input type="submit" ... />
    </form>
    </tr>
    

    Above code is common for single row update option. Then your update SQL will look something like:

    sqlString = "Update tableName Set updatableFiled ='" + data + "' where recordID = " + recordID;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,

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.