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 6173947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:39:51+00:00 2026-05-23T23:39:51+00:00

This is strange… I’m displaying results in an HTML table but I’m getting a

  • 0

This is strange… I’m displaying results in an HTML table but I’m getting a different number of results being displayed depending on if/how I am debugging. If I debug slowly and hit each line then all of the results show. If I just run it or don’t step through each line then I only get one result in the table. Either way the result set does have the correct number of rows, they just aren’t being displayed in the table correctly.

Does anyone have any ideas why this strange behavior is happening? I’m using Eclipse Indigo. Below is the block of code that I’m using to select the records and display them.

      try {
     String query =
     "Select * from plants where name = '"
     + name + "'";
     String plantName = "";
     ResultSet rs = sttmnt.executeQuery(query);

 while (rs.next()) { // display information for each plant.
        plantName = rs.getString(2);  // display fields in cells
        out.println("<tr><td>");
        out.println(plantName + "</td><td>");
        out.println(rs.getString(3) + "</td><td>");
        out.println("$" + rs.getString(5) + "</td><td>");
        out.println(rs.getString(4) + "</td>");
        out.println("<input type=\"hidden\" name=\"plantName" +
         plantNo + "\" value=\"" + plantName + "\">");
        out.println("<input type=\"hidden\" name=\"plantID" +
         plantNo + "\" value=\"" + rs.getString(1) + "\">");
        out.println("</tr>");
        plantNo++;
     }
     if (plantNo == 0) out.println("<tr><td align=\"center\" " +
          " colspan=\"4\">Sorry, there are currently no " + name
          + " plants for sale.</td></tr>");
     else
         out.println("<tr><td align=\"center\" " +
                 " colspan=\"4\">Showing " + plantNo
                 + " results. </td></tr>");

     out.println("</table>");
     rs.close();
  }
  • 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-23T23:39:53+00:00Added an answer on May 23, 2026 at 11:39 pm

    Try appending all the output to a StringBuffer and print that all out in one fell swoop. You’ll save on objects, too. Your code becomes:

    try {
     String query = "Select * from plants where name = ?";
     sttmnt.setString(1, name);
     String plantName = "";
     ResultSet rs = sttmnt.executeQuery(query);
    
     StringBuffer output = new StringBuffer(); 
     while (rs.next()) { // display information for each plant.
        plantName = rs.getString(2);  // display fields in cells
        output.append("<tr><td>");
        output.append(plantName + "</td><td>");
        output.append(rs.getString(3) + "</td><td>");
        output.append("$" + rs.getString(5) + "</td><td>");
        output.append(rs.getString(4) + "</td>");
        output.append("<input type=\"hidden\" name=\"plantName" +
         plantNo + "\" value=\"" + plantName + "\">");
        output.append("<input type=\"hidden\" name=\"plantID" +
         plantNo + "\" value=\"" + rs.getString(1) + "\">");
        output.append("</tr>");
        plantNo++;
     }
     if (plantNo == 0) output.append("<tr><td align=\"center\" " +
          " colspan=\"4\">Sorry, there are currently no " + name
          + " plants for sale.</td></tr>");
     else
         output.append("<tr><td align=\"center\" " +
                 " colspan=\"4\">Showing " + plantNo
                 + " results. </td></tr>");
    
     output.append("</table>");
     out.println(output.toString());
     rs.close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this strange error while processing a large number of data... Error Number:
I can't remember exactly where I've seen this strange `1 (single-tick and the number
Trying to install pear package and keep getting this strange error. Can you shed
This' strange because all my other NSUrls in program are working properly but this
Getting this strange error. In C#, I write to a file (txt) whose location
I have this strange scenario. I have a table having multiple rows (each generated
I'm getting this strange behavior when fetching a website using socket. The string returned
I'm having this strange error for the devise_invitable extension: uninitialized constant ActiveSupport::SecureRandom But the
I'm getting this strange error when I try connect to my WCF with webHttpBinding
I'm having this strange problem where an undesired space is being produced when changing

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.