Why is the second row in the recordset not updated?

Hi,
I have this problem.
I have written a servlet named processPOItem.
The following is the doPost Method in the processPOItem class:
public class processPOItem extends HttpServlet {
//attributes
public String strPO;
ConnectionPool connectionPool = null;
protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
        int counter=0, remainder=0;
        String SearchPOItems;
        String strStatus, ISBN;
        String price;
        response.setContentType("text/html"); //html output
        PrintWriter out = response.getWriter();
        //get the parameter named PO
        strPO = request.getParameter("PO");
        Connection dbConn = null;
        try{  
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Purchase Order " + strPO + "</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<table width=600 border=0 align=center>");
            out.println("<tr>");
            out.println("<td colspan=4 align=center>");
            out.println("<font face=Arial size=2>");
            out.println("<b>Purchase Order: " + strPO + "</b>");
            out.println("</font>");
            out.println("</td>");
            out.println("</tr>");
            out.println("</table>");
            out.println("<form method=post action=processPOItem>");
            out.println("<input name=updatePO type=hidden value=1>");  
            out.println("<table width=800 border=0 cellspacing=1 cellpadding=0 align=center>");
            out.println("<tr bgcolor=\"#990000\">"); //Display the mb_PurchaseItem
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">No</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">ISBN</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">Title</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">Status</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">Quantity</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">Unit Price</font></b></td>");
            out.println("<td align=center><b><font size=1 face=Verdana color=\"#FFFFFF\">Delivered Date</font></b></td>");
            out.println("</tr>");
            //get the SQL statement
            SearchPOItems = searchSQL(strPO);
            //get free connection from Pool
            dbConn = connectionPool.getConnection();
            //create a statement object
            Statement stmt = dbConn.createStatement();
            //create the recordset
            ResultSet rs = stmt.executeQuery(SearchPOItems);
            //display the recordset
            while (rs.next())
                counter++;
                remainder = counter % 2;
                if (remainder == 0)
                   out.println("<tr bgcolor=\"#C1C1C1\">");
                else
                   out.println("<tr bgcolor=\"#E1E1FF\">");
                //Display the individual Purchase item under the customer
                out.println("<td align=center><font size=1 face=Verdana>" + counter + "</font></td>");
                ISBN = rs.getString("mb_ISBN");
                out.println("<td align=center><font size=1 face=Verdana>" + ISBN + "</font></td>");
                out.println("<td align=center><font size=1 face=Verdana>" + rs.getString("mb_Title") + "</font></td>");
                strStatus = rs.getString("mb_Status");
                out.println("<td align=center><font size=1 face=Verdana>");
                out.println("<select name=\"mb_Status" + ISBN + "\">");
                out.println("<option value=PENDING");
                if (strStatus.equals("PENDING"))
                   out.println("selected>Pending</option>");
                else  
                   out.println(">Pending</option>");
                out.println("<option value=PROCESSING");
                if (strStatus.equals("PROCESSING"))
                   out.println("selected>Processing</option>");
                else  
                   out.println(">Processing</option>");               
                out.println("<option value=DELIVERED");
                if (strStatus.equals("DELIVERED"))
                   out.println("selected>Delivered</option>");
                else  
                   out.println(">Delivered</option>");
                out.println("<option value=CANCELLED");
                if (strStatus.equals("CANCELLED"))
                   out.println("selected>Cancelled</option>");
                else  
                   out.println(">Cancelled</option>");
                out.println("</select>");
                out.println("</font>");      
                out.println("</td>");
                out.println("<td align=center><font size=1 face=Verdana>" + rs.getString("mb_Qty") + "</font></td>");
                /*price = rs.getString("mb_Price");
                NumberFormat moneyAmount = NumberFormat.getCurrencyInstance();
                Double dPrice = Double.parseDouble(price);
                out.println("<td align=center><font size=1 face=Verdana>" + rs.getString("mb_Price") + "</font></td>");
                out.println("<td align=center colspan=2><font size=1 face=Verdana>");
                if (strStatus.equals("DELIVERED"))
                    //status = "DELIVERED"
                    out.println("<input align=center name=\"deliveredDate" + ISBN + "\" type=text size=10 maxlength=10 value=" + rs.getString("mb_DeliveredDate") + ">");    
                else
                    out.println("<input align=center name=\"deliveredDate" + ISBN + "\" type=text size=10 maxlength=10 value=Nil disabled>");
                out.println("</font>");   
                out.println("</td>");
                out.println("</tr>");
            out.println("<tr><td> </td></tr>");
            out.println("<TR>");
            out.println("<TD colspan=3 align=center>");
            out.println("<INPUT TYPE=submit BORDER=1 value=update name=update>");
            out.println("</td>");
            out.println("<TD colspan=3 align=center>");
            out.println("<a href=\"javascript:window.close()\"><img src=\"Close.gif\" BORDER=0></a>");
            out.println("</td>");
            out.println("</tr>");
            out.println("<tr>");
            rs.close();  
            stmt.close();
            out.println("</form>");
            out.println("</table>");
            out.println("</body>");
            out.println("</html>");
            out.close();
        catch (Exception e)
            //sendErrorToClient(out, e); //send stack trace to client
            System.out.println(e.getMessage());
        finally{
            //return connection to Pool
            connectionPool.returnConnection(dbConn);
protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
           response.setContentType("text/html"); //html output
           PrintWriter out = response.getWriter();
           Connection dbConn = null;
           //get the parameters posted back by processPOItem servlet
           String processingAll = request.getParameter("processingAll");
           String deliveredAll = request.getParameter("deliveredAll");
           String deliveredDate = request.getParameter("deliveredDate");
           String refInvoice = request.getParameter("refInvoice");
           String refNumber = request.getParameter("refNumber");
           //String status = request.getParameter("status");  
           //check if update button is pressed
           String updatePO = request.getParameter("updatePO");
           //sql statement variable
           String sqlUpdatePOStatus;
           String isbn, poItemStatus;
           //update button was pressed
           if (!updatePO.equals(""))
            try{
                //get the SQL statement
                String SearchPOItems = searchSQL(strPO);
                //get free connection pool
                dbConn = connectionPool.getConnection();
                //create a statement object
                Statement stmt = dbConn.createStatement();
                //create the recordset
                ResultSet rs = stmt.executeQuery(SearchPOItems);
                int index = 0;
                //display the recordset
                while (rs.next())
                  isbn = rs.getString("mb_ISBN");
                  poItemStatus = request.getParameter("mb_Status" + isbn);
                  out.println(isbn + " " + poItemStatus);
                  out.println("<br>");
                  //update the status of individual PO item
if (!poItemStatus.equals(""))
sqlUpdatePOStatus = updatePOItemSQL(strPO, isbn, poItemStatus);
stmt.executeUpdate(sqlUpdatePOStatus);
                rs.close();  
                stmt.close();
                out.close();
            catch (Exception e)
                System.out.println(e.getMessage());
            finally{
                    //return connection to pool
                    connectionPool.returnConnection(dbConn);
}When I perform a form submit in my doGet() method, the doPost Method() responsed. However, it encounter error in updating the second row in the recordset as highlighted in bold.
After the first row is updated. The second row did not get updated at all.
The error return was "Resultset is closed".
What actually is wrong? How can I execute a sqlstatement inside a recordset? How to solve this problem?

Did you turn on the "updatable" switch for the result
set?
public Statement createStatement(int resultSetType,
int resultSetConcurrency) throws
SQLException
Parameters:
resultSetType - a result set type; see
ResultSet.TYPE_XXX
resultSetConcurrency - a concurrency type; see
ResultSet.CONCUR_XXX
static int CONCUR_UPDATABLE
JDBC 2.0 The concurrency mode for a ResultSet object
that may be updated.Hi,
do you refer to the following change of code:
//create a statement object (original)
Statement stmt = dbConn.createStatement();change to the following:
//create a statement object (original)
Statement stmt = dbConn.createStatement(resultSetType,
resultSetConcurrency);when I use another statement object for executeupdate, what I got was the connection was used by another hstmt. Thus the second column was not updated at all.
Why?

Similar Messages

  • I've just started using the App Tabs. I think this feature could be handy but why are the sites not updated when I start Firefox. Now I have to manually update the site which is somewhat of a downer. Does any of you know where I'm going wrong?

    I've just started using the App Tabs. I think this feature could be handy but why are the sites not updated when I start Firefox. Now I have to manually update the site which is somewhat of a downer. Does any of you know where I'm going wrong?

    To answer the post title FireFox save all downloads automatically in the download folder, which you can find in the Documents folder. If you want to choose where to save your downloads go to tools>options>check always ask me where to save files.
    Secondly, I am assuming you have IE 8 installed as this is the only version that supports this fix that is currently not in beta. Go to control panel>internet options>advanced tab and reset the settings at the bottom. This may or may not fix the problem but it is a good first step.

  • Why is the app not updating automatically with NEW APP

    I've subscribed to a few podcasts but they won't update automatically and in some cases it won't find the podcast in question.
    I can find the podcast in iTunes and it says I'm subscribed but it doesn't want to down load or has issues with the buttons on the screen so I can't press the down load button. Please help.

    if you can connect to btwifi without the app then I wouldn't bother trying to find the apk file
    if you have an android smartphone then you can download the app and get the apk file to sideload on to your nook
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • TS3694 Why is the IPAD not updating to the new Operating System. I get this 3014 error all the time. Help please?

    I just updating to the new operating system.  My Ipad is having problems updating to the new operatinng system IO6 I think.  Anyways I keep getting this 3014 error.  Is anyone else experiencing this problem?

    I am having the same problem.  I think I saw something about VPN and not being able to communicate with Apple web site.  Do you have your protected company email on your phone?

  • Why are the iPhotos not listed in the finder?

    why are the iPhotos not listed in the finder?

    There are many, many ways to access your files in iPhoto:   You can use any Open / Attach / Browse dialogue. On the left there's a Media heading, your pics can be accessed there. Command-Click for selecting multiple pics.
    (Note the above illustration is not a Finder Window. It's the dialogue you get when you go File -> Open)
    You can access the Library from the New Message Window in Mail:
    There's a similar option in Outlook and many, many other apps.  If you use Apple's Mail, Entourage, AOL or Eudora you can email from within iPhoto.
    If you use a Cocoa-based Browser such as Safari, you can drag the pics from the iPhoto Window to the Attach window in the browser.
    If you want to access the files with iPhoto not running:
    For users of 10.6 and later:  You can download a free Services component from MacOSXAutomation  which will give you access to the iPhoto Library from your Services Menu.
    Using the Services Preference Pane you can even create a keyboard shortcut for it.
    For Users of 10.4 and 10.5 Create a Media Browser using Automator (takes about 10 seconds) or use this free utility Karelia iMedia Browser
    Other options include:
    Drag and Drop: Drag a photo from the iPhoto Window to the desktop, there iPhoto will make a full-sized copy of the pic.
    File -> Export: Select the files in the iPhoto Window and go File -> Export. The dialogue will give you various options, including altering the format, naming the files and changing the size. Again, producing a copy.
    Show File:  a. On iPhoto 09 and earlier:  Right- (or Control-) Click on a pic and in the resulting dialogue choose 'Show File'. A Finder window will pop open with the file already selected.    3.b.
    b: On iPhoto 11 and later: Select one of the affected photos in the iPhoto Window and go File -> Reveal in Finder -> Original. A Finder window will pop open with the file already selected.

  • Why is my ipad keep restarting almost every 5 minutes and also why is the screen not rotating.

    why is my ipad keep restarting almost every 5 minutes and also why is the screen not rotating.

    Nobody here can answer a question like that. Try rebooting your iPad and see if that helps.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • I can no longer edit the info for my songs, movies and tv shows.  This occurred since I loaded Windows 7 Pro on my C drive, and then fownloaded ITunes 10.  Why will the program not allow me to access the track info to edit it?

    I can no longer edit the info for my songs, movies and tv shows.  This occurred since I loaded Windows 7 Pro on my C drive, and then fownloaded ITunes 10.  Why will the program not allow me to access the track info to edit it?

    Ah yes school boy error there out of frustration and discontent..
    My issue is with music/apps/films etc not downloading from iTunes / App Store.
    They initially fail and message is displayed stating unable to download / purchase at this time, yet if I retry it says I've already purchased (?) or alternatively I go to the purchased section and there they are waiting with the cloud symbol..
    However some items get frozen in the download window and cannot be retried or deleted. Message appears stating to tap to retry, but even if you stole every bath and sink in the uk you'd still not have enough taps.
    I post here as the iTunes guys are useless in there 'help' and have only advised posting here or phoning apple, at my expense, to explain a problem that could be rectified by forwarding my original email to a techie. However the tech team apparently don't have an email address as they're from ye olde Middle Ages..!
    Anyways I digress.
    So I tried sync to pc, but instead of showing the file as ready to listen/use/view, the iCloud symbol shows and I'm back to square one as the item is unable to download..
    At frustration station waiting for a train from pain...
    All my software is up to date, and had all worked fine prior to the last big iOS update that resulted in all the changes in display and dismay.
    Answers in a postcard :-)
    Much love

  • Why is the app not available for my device?

    I've no problem using BT wifi on my device (Nook BNTV400) so why is the app not available for that device? It's not like the nook is proprietory, everything else I've tried to find in the play store works fine.
    Is the apk available for download direct from bt?

    if you can connect to btwifi without the app then I wouldn't bother trying to find the apk file
    if you have an android smartphone then you can download the app and get the apk file to sideload on to your nook
    If you like a post, or want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • Why is the text not the visible in the protected PDF opened on Mac?

    Long story short:
    I've created a document in Microsoft Word 2010 and saved it as PDF. With the .pdf open now in Acrobat Reader 9.4.1 I have enabled the protection over the .pdf file by only allowing Printing and saved the protected .pdf. All of these actions are made on Windows 7 machine. Now when trying to open the protected .pdf on Mac (with Snow Leopard 10.6.6 and Preview) the .pdf opened only shows the lines and bullets but not the text.
    Why is the text not visible in the protected PDF opened on Mac?
    (is this bug or a "feature"?)
    Note: the protected .pdf looks good on Windows 7 and it works on Mac if the .pdf has no protection.
    Thanks!

    A. What application are you using to add the protection? Reader cannot add any file security and I don't think the PDF feature of Word will either.
    B. Mac Preview has issues with PDF standards so there may be some features that you will experience issues with that have no workarounds.
    C. Have you checked the file after adding security to see if all fonts are embedded?

  • Why is the map not displaying correctly on "find my phone"  I am getting large grid squares on the map

    why is the map not displaying correctly on "find my phone"  on my computer.  I am getting large grid squares on the map.  I have tried deleting my history, tried zooming in & out, but the grid squares won't go away..

    Welcome to Apple Support Communities
    It means that it is not connected to the Internet, so it may be turned off. Another option would be that somebody has resetted it to default settings and has changed the Apple ID, being impossible to track your son's iPhone. Anyway, report it to the police because it is the only thing you can do at the moment

  • Why is the template not being used when dynamic page called ?

    Hi,
    I have created a dynamic page and assigned a template to it. When I call the dynamic page using the 'show' procedure from a form, I do not see the template.
    Why is the template not being used ? How can I get the template working when I call the dynamic page ?
    I even tried to show the page from the dynamic page's manage components tab and there is same problem. Template is not being used.
    thanks,
    Mainak

    You can alter the generated package body to include the following function in the header and footer sections.
    Header:
    PORTAL.wwv_headings.show_header(
    p_template => 'PUBLIC.TEMPLATE_3',
    p_heading => 'Dynamic Page',
    p_help_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.help',
    p_about_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.about');
    Footer:
    PORTAL.wwv_headings.show_footer(
    p_template => 'PUBLIC.TEMPLATE_3',
    p_help_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.help');
    where
    <PORTAL_DEMO> indicates application schema
    <PORTAL> indicates the name of the portal (normally this will be portal30 by default).

  • Why does the charger not charge my battery?  I just bought and installed a new battery from Apple (direct) today

    Why does the charger not charge my battery?  I just bought and installed a new battery from Apple (direct) today

    yes, the charger was working before. 
    so far i have:
    1.  updated my software
    2.  updated to battery 1.2
    3.  took off the "duck" plug and used the macbook pro cord that was provided
    4.  checked and cleaned the pins on the magsafe
    5. checked and cleaned the magsafe port
    any ideas?  i appreciate your response!

  • Why does the trash not fully empty?

    Why does the trash not fully empty?

    try this:
    in the finder, choose empty trash from the finder menu while holding the option key.
    if that doesn't work, see this article on how to resolve Trash Problems.

  • Why Does the iPhone not send/receive MMS?

    Why Does the iPhone not send/receive MMS? this in the works?

    "Why Does the iPhone not send/receive MMS?"
    Apple chose not to offer this as a feature of iphone. E-mail can accomplish the same thing.
    "is in the works?"
    This has been asked and answered countless times. The forum search bar is on the right side of this page.
    Apple has announced that MMS will be included in the 3.0 software due out this summer. Before you ask, all that has been announced is in this link:
    http://www.apple.com/iphone/preview-iphone-os/
    Apples developer conference begins tomorrow.

  • Why does the page not move smothe when i scroll?

    Why does the page not move smothe when i scroll?
    Sometimes it even move slower then i Scroll?
    I use a Mac and i have tried to reinstall the program.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    In Firefox 4 [http://kb.mozillazine.org/Safe_mode Safe mode] disables extensions and disables hardware acceleration.
    * Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
    See:
    * [[Troubleshooting extensions and themes]]

Maybe you are looking for