Help!!!! jsp deletion issues

hi
i have made a table using jsp to show the contents of a table from a database in a tabular format. the table rows have two options edit and delete. edit will show all the data in textboxes. this some how works.
delete option is giving one bug and one error
error: ResultSet is closed
bug: the data is being deleted. but instead of the row i want to be deleted,
only the first row is being deleted.
i am using SQLServer 2000 as my database;
i am using Apache Tomcat 5.5.17 as my webserver;
here is my code:
<%@ page errorPage="err.jsp" %>
<%@ page import="java.sql.*;" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:empdsn");
Statement st= con.createStatement();
Statement st2= con.createStatement();
//Statement st= con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs= st.executeQuery("select * from employeetable");
%>
<html>
<head>
     <title>Employee Details</title>
</head>
<style>
     .myLnk
          color:#FF0000;
          text-decoration:none;
     .myLnk:hover
          color:white;     
          text-decoration:underline;
</style>
<body bgcolor="#B7CEEC">
<table align="center">
     <tr bgcolor="#808000">
     <th>employee id</th>
     <th>employee name</th>
     <th>employee address</th>
     <th>employee salary</th>
     <th colspan="2">options</th>
     </tr>
<%
String color="";
String act=request.getParameter("act");
String id=request.getParameter("id");
int i=1;
while(rs.next())
String empId=rs.getString(1);
if(i%2==0)  color="#0000A0";
else  color="#0000FF";
          if(act!=null && id!=null)
               if(act.equals("edit"))
          %>
          <form action="" name="empform">
          <table align="center">
          <tr>
               <td> <input type="text" name="textid" value="<%= empId %>"></td>
               <td><input type="text" name="textname" value="<%= rs.getString(2) %>"></td>
               <td><input type="text" name="textaddress" value="<%= rs.getString(3) %>"></td>
               <td><input type="text" name="textsalary" value="<%= rs.getString(4) %>"></td>
          </tr>
          </table>
          </form>
          <% }
          else if(act.equals("delete")){
                     //rs.absolute(Integer.parseInt(empId));
                     //rs.deleteRow();
                      //rs.updateRow();
                      out.println(empId);
                    int delres= st.executeUpdate("delete from employeetable where empid='"+empId+"'");
                    //ResultSet rs1= st.executeQuery("select * from employeetable");
                    while(rs.next())
               //     String delEmpId=rs1.getString(1);
               //     int delres= st.executeUpdate("delete from employeetable where empid='"+delEmpId+"'");
                    %>
                    <h1><font color="red" size="">DELETED SUCESSFULLY</font></h1><br>
                    <tr bgcolor="<%= color%>" style="color:white;font-weight:bold;">
           <td><%= rs.getString(1) %></td>
           <td><%= rs.getString(2) %></td>
           <td><%= rs.getString(3) %></td>
           <td><%= rs.getString(4) %></td>
                    </tr>
               <% 
               //st2.executeUpdate(update_table);
               %>
          <% }else{ %>
           <tr bgcolor="<%= color%>" style="color:white;font-weight:bold;">
           <td><%= empId %></td>
           <td><%= rs.getString(2) %></td>
           <td><%= rs.getString(3) %></td>
           <td><%= rs.getString(4) %></td>
           <td><a href="showEmployeeTable.jsp?act=edit&id=<%=empId%>" class="myLnk">Edit</a></td>
           <td><a href="showEmployeeTable.jsp?act=delete&id=<%=empId%>" class="myLnk">Delete</a></td>
           </tr>
           <% }
           %>
<%
     i++;
  %>
</table>
</body>
</html>
can u please help me fix this? thanx in advance
shankha

hi j_shadinata,
thanks for sharing your valuable knowledge with me!
1.
your code is so messy... instead putting list,
update, delete in one jsp, seperating them to 3 jsp
pages (list/show, update & delete).
answer: yes i could have broken it up into 3 jsp pages and it would have been easier. but the requirement was such that all 3 functions of list/show, update & delete had to be done on a single jsp page
2.
int delres= st.executeUpdate("delete from
employeetable where empid='"+empId+"'");empId value is from rs.next(), rs.getString(1). so it
will delete first row.
perhaps you want to do this:
int delres = st.executeUpdate("delete from
employeetable where empid ='" + id + "'");
i dont understand where did id come from. where do i declare this id? could you please explain?
3. how do i fix the error message : "ResultSet is closed "
thanks for all your help!!!
shankha

Similar Messages

  • Can you help me delete photo library & duplicate photo library

    Hi,
    I don't know what I did, but I somehow copied 44 of my daughter's music images into my photo library and then created a duplicate with 43 images.  These 87 images are taking up room and there is no obvious way to delete them. 
    Here's what happens when I touch camera roll it brings me to the photo library -- where 43 out of 44 images are hers:
    I click edit and the only options are share via email, faceboook, twitter, etc. or add to which leads to create a new album.  I don't want to do any of this.  I just want to delete them to make room.
    The same options apply for the Duplicate album as well.
    Can you help me delete the photo library and the duplicate library on my phone?  I only want to keep one video in the camera roll and all of the rest of the images can go.
    Thanks!

    Thanks for your response.  I think you just isolated my issue -- I was trying to upload music and somehow wound up syncing my daughter's photos to my iphone.  I don't know how to delete them because not all of the album/folders are appearing there.  Do you have any suggestions on how to find them?

  • Since having installed Yosemite my adobe acrobat X crashs as soon as I want to open a file, can anyone help on this issue?

    Since having installed Yosemite my adobe acrobat X crashs as soon as I want to open a file, can anyone help on this issue?

    Please try the steps below and let me know if it worked for you
    Delete all the files from following folders:
    [Home]/Library/Application Support/Adobe/SLStore
    [Home]/Library/Application Support/Adobe/SLCache
    And, delete all files from following folder except cache.db
    [Home]/Library/Application Support/Adobe/AdobePCD
    Then launch Acrobat and try to activate and check.
    Regards,
    Rave

  • HT5316 I've been working with Mainstage 2.1.3 and have experienced concerts crashing immediately after loading.  I'm not installing Mainstage 2.2.2 to see if that helps alleviate the issue.  My question is: should I uninstall Mainstage 2.1.3 now?

    Hi all,
    I've been working with Mainstage 2.1.3 and have experienced concerts crashing immediately after loading.  In an attempt to solve crash issue, I've installed Mainstage 2.2.2 to see if that helps alleviate the issue.  My question is: should I uninstall Mainstage 2.1.3 now in order to save memory?
    thanks,
    korriefromca

    Hi
    korriefromca wrote:
    My question is: should I uninstall Mainstage 2.1.3 now in order to save memory?
    You would only save about 500MB by deleting MS 2.1.3. You may find it useful to keep the application, or perhaps to make a zip and then delete the original
    CCT

  • Is there a phone number I can call to talk to a live person about help with Lightroom issues ?

    Is there a phone number I can call to talk to a live person about help with Lightroom issues ?

    well the reason I wanted to talk to someone live because it would take forever to explain everything on here But anyway, here goes. I have an HP Pavilion Notebook with Intel Core i5-323om CPU @2.60 GHz and 8 gb ram 64bit. I am trying to run Lightroom 5.7 on my laptop and having major issues. I use an external hard drive for the storage of my photos. When I try to use Lightroom I run into many issues: Flickering of the screen, freezing up, slow, the loading circle just goes round and round lol. If I go to the washroom or leave the computer for even a minute it freezes up. I have to keep pressing Ctr/alt/delete to bring it back when it flickers. I have to constantly exit out of the program and restart it to be able to edit even just a couple of photos and then it starts acting up again.
    I have tried un-installing and re-installing, updating everything on my pc, changing compatibility settings, updating development settings, I even took the laptop into have it looked at and they did all kinds of updates etc...and still couldn't figure out why it wasn't working for me. I have gone through the lists of troubleshooting for LR problems and there just seem to be nothing that works.....I have made new catalogues, moved them, tried using the software on my pc without the EHD, etc etc.......I have tried EVERYTHING...I think.....so I was looking for some answers as to why this is happening....

  • Help in DELETE script

    Hi, I have duplicate records and want to delete any 2nd duplicate row. Please help in DELETE script.
    Select * from cmhrec
    Sr_no  code    date     charge   Charge2 Code_ID
    1        AAA   1-1-2014  24.0      24.0      5
    1        AAA   1-1-2014  24.0      24.0      9
    2        AAA   1-1-2014  23.0      23.0      4
    2        AAA   1-1-2014  23.0      23.0      11
    3        AAA   1-1-2014   26.0      28.0     12
    3        AAA   1-1-2014   26.0      28.0     19
    --Desired output after deleting any 2nd duplicate row.
    Sr_no  code    date     charge   Charge2 Code_ID
    1        AAA   1-1-2014  24.0      24.0      5
    2        AAA   1-1-2014  23.0      23.0      4
    3        AAA   1-1-2014   26.0      28.0     12

    Thank you
    You can simply do this
    DELETE t
    FROM cmhrec t
    WHERE EXISTS
    SELECT 1
    FROM cmhrec
    WHERE SrNo = t.SrNo
    AND Code = t.Code
    AND Code_ID < t.Code_ID
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Need help on FSCM issue

    Hi All,
    Need your help on FSCM issue.
    We had an customer invoice posted through an interface . The invoice base line date is 12/16/2008 (due 30 days), interest is calculated for this invoice on 02/01/2009.
    The actual invoice amount is Rs 238.69 and the interest amount is Rs 2.00. Also the invoice is dunned on 03/03/2009 for amount 240.69 (including the interest amount).
    The document shows as open in UDM_Specialist for amount 240.69 for a particular specialist. The invoice is cleared on 03/16/2009. Though it is cleared still shows in UDM_Specialist with amount 0.0.
    Once the invoice is cleared it should not exist in UDM_Specialist. We have tried the same scenario but the functionality is working fine in Development.
    Please tell me your valuable suggestion in this regard.
    Thanks in advance.
    Regards,
    Jayasudha

    showsessionvalue.jsp:
    <%@ page language="java" %>
    <%
    String username=(String) session.getAttribute("username");
    if(username==null) username="";
    %>
    <html>
    <head>
    <meta http-equiv="refresh" content="<%=session.getMaxInactiveInterval()%>;url=logout.jsp">
    <title>Show Saved Name</title>
    </head>
    <body>
    <form name="action1" action="savenametosession.jsp">
    <% if (username == "") { %>
    <p> Invalid session </p>
    <%} else {%>
    <p>Welcome: <%=username%><p>
    enter name <input name="username" maxlength="75">
    enter age <input name="age" maxlength="3">
    <button type="submit" name="submit">submit </button>
    <br>
    <a href = "logout.jsp">logout </a>
    <%System.out.println(session.getLastAccessedTime());%>
    <%}%>
    </form>
    </body>
    Hello every one,
    Thanks for your reply.
    In show showsessionvalue.jsp I am just setting up the session id.
    Let me first describe my requirement. I need to set a default session value<let it be 30sec>, so that when the user is ideal for that session value he should be logged out automatically. Else if he keeps the web page activate then he should not be logged out. And on the same hand if the user is ideal for some period, and come back with in the session limit then the session timer should be stopped and vice versa.
    In the above code what the problem I face is that even if I keep my browser busy it logouts me after at 1 sec as I specified in the XML.
    Thank you,

  • I've installed CS6 and web Premium on a Mac running 10.9.5, and Dreamweaver,Flash and Illustrator wont launch.  All other components work normally.  In Activity monitor it says Adobe switchboard failed to respond.  Can anyone help solve this issue?

    I've installed CS6 and web Premium on a Mac running 10.9.5, and Dreamweaver,Flash and Illustrator wont launch.  All other components work normally.  In Activity monitor it says Adobe switchboard failed to respond.  Can anyone help solve this issue?

    Release: 4/25/2012
    http://support.amd.com/us/gpudownload/windows/Pages/radeonmob_win7-64.aspx

  • Can anyone help me deleted this existing photos in my photo library.i already did to sync it up on itunes ang remove all photos ang sync.but still there is 5 photos in my general about eventhough my camera roll is empty.plsss help.thanks.

    can anyone help me deleted this existing photos in my photo library.i already did to sync it up on itunes ang remove all photos ang sync.but still there is 5 photos in my general about eventhough my camera roll is empty.PLEASE HELP!Thanks.

    i mean "and" not "ang" btw.

  • HT1365 Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    Hi can anyone help with this issue regarding my wireless magic mouse? When im on google chrome and scrolling down the page i always have youtube running in the background but the audio cuts/spits/pops can anyone help me with this?

    The figures you mention only make sense on your intranet.  Are you still using the same wireless router.  The verizon one is somewhat limited as far as max wireless-n performace.  For one thing it only has a 2.4 radio.   I like many people who wanted wireless-n performance before they even added a wireless-n gigabit router, have my own handling my wireless-n network.

  • I have a USB cable for my iPod touch 4th gen. I have tried almost everything to make my windows computer find my iPod touch but its not finding it. Any help on this issue?

    I have a USB cable for my iPod touch 4th gen. I have tried almost everything to make my windows computer find my iPod touch but its not finding it. Any help on this issue?

    If not successful:
    Try DFU mode and then restore
      How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    Try another USB port and cable
    Try another computer to help determine if you have an iPod or computer problem

  • EMail on my iPhone 4s is no longer synching right with my Mac. Things I delete on my Mac are still on my iPhone. HELP!  Deleting in both places is so time consuming. It has worked until recently...not sure what changed!

    Things I delete on my Mac are still on my iPhone. HELP!  Deleting in both places is so time consuming. It has worked until recently...not sure what changed!

    Your email provider may have changed certain settings to do with deleting from server when deleting from client so that it no longer works. Are you using pop or imap? If pop then recreate the account using imap.

  • Since updating to FF 8 I can no longer use Multirow book marks, can anyone help with this issue?

    Since updating to FF 8 I can no longer use Multi-row book marks, can anyone help with this issue? the one I used is here http://multirowbookmarkstoolbar.com/

    Try the support site:
    *http://multirowbookmarkstoolbar.com/forum
    *Multirow Bookmarks Toolbar Plus: https://addons.mozilla.org/firefox/addon/multirow-bookmarks-toolbarplus/

  • Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Have just down loaded Yosemite over Mountain Lion, Indesign CS5 does not work ( Am dependant on it) although Bridge , Light Room and Elements operate OK How do I solve this rapidly. Can any one help on this issue. Thanks

    Sorry to say it, but I think you can see from Bob's response that there's no way to solve this rapidly.
    Did you take an image of your Mountain Lion install before upgrading to Yosemite? Roll back to that. If you're not in the habit of taking a snapshot of your system before performing operating system upgrades - get in that habit. If you are dependent on anything at all on hour computer, having a reliable backup method in place is essential. If you don't have a Time Capsule, or some other way to run Time Machine onto a disk that's not in your computer, go set that up yesterday.
    If you can't just remove Yosemite and roll back to Mountain Lion for whatever reason, you can partition your drive so that you can install both Yosemite and Mountain Lion on the same drive, and then boot into Mountain Lion when you need to work in CS5. Or you can take your Mountain Lion disc (I assume you have one, no?) and then use it to create a virtual machine in something like VirtualBox to run Mountain Lion from inside Yosemite.

  • Re: Firefox no longer works with Mac OS X 10.5, will upgrading to Lion, OS X 10.7, help with this issue?

    I cannot upgrade my Mac to Mountain Lion, OS X 10.8 and cannot buy a new Mac so will upgrading from
    OS X 10.5 to OS X 10.7 help with this issue?

    If you are going tob e upgrading to 10.7 you should be able to just upgrade, and then install future updates of Firefox with no problem.

Maybe you are looking for

  • How do I install the NVIDIA 4000 card?

    I am putting in the Nvidia Quadro 4000 graphics card in my early 2008 Mac Pro 3,1.  I installed my RAM as well as my hard drives but I must admit this is something I have not done before to this extent. Do I need to be grounded? And does someone know

  • To create a check box list having values updated as on click

    hi i am working on jDeveloper My scenario is like this Select Payee : # All # Stamp duty 21212 # Loan 12122 Total -- ______ *# represent check box* so if i click on any of the check box its values need to dynamically updated in the Total . I have use

  • Can you open a calculator and add or subtract within a cell?

    I am trying to see if there is a way to use the number pad as a calculator and add figures then enter into a cell for further use.  I want to eliminate the use of my adding machine if possible and just use my keyboard to do my additions and enter dir

  • How to get two empty columns in reporting?

    Hi Experts, How to get Two empty columns in  a report, i have taken a formula and i have given '=0' in the formula box after executing the query that two columns containing zero's, but i don't want zero's, i want to display empty columns. pl help to

  • How to print in PL Sql using a procedure?

    So how do you create a procedure to print a name in PL Sql ? Here is what I have done so far. Create Procedure Print_Info ( X_Name IN Varchar2 ) As Begin :X_Name:='Anabella' DBMS_Output.Put_Line (X_Name); End Print_Info; thanks