title: How to add all row elements in database to JSON object
body: <p>I'm trying to retrieve all elements in database and display in webpage.But with my code it able to retrieve only one row element. Problem is, it retrieves all element but it adds the last row element to the object. I think all elements retrieved first are overwritten Because of that it displays last row element. Can anyone tell me how add all row elements to the JSON object. Please help me.</p>
  
  <p>code :</p>
  
  <pre><code>            while(rs.next()){
                  ImageFile.setName(rs.getString("imagename").trim());
                  ImageFile.setDisc(rs.getString("imagedisc").trim());
                  ImageFile.setImageid(rs.getInt("imageid"));
                  ImageFile.setalbumid(rs.getInt("albumid"));
  
                  byte imageData[] = rs.getBytes("imagethumb");
                  String encoded = DatatypeConverter.printBase64Binary(imageData);
                  ImageFile.setThumb(encoded);
  
                  byte image1Data[] = rs.getBytes("imagethumb");
                  String encoded1 = DatatypeConverter.printBase64Binary(image1Data);
  
                  ImageFile.setFull(encoded1);
              }                                                                        
  </code></pre>
  
  <p><strong>The complete source code is in <a href="https://stackoverflow.com/questions/14777159/retrieving-images-using-jquery-and-servlet-produces-http-status-500-error">this</a> question</strong></p>
  
  <p>Please help me........Thanks....</p>