title: ArrayList in java printing last inserted value?
body: <p>I have following java class</p>
  
  <pre><code>package com.picvik.model;
  
  import java.util.Date;
  
  public class ViewAlbum {
  
  private Integer albumid;
  private String albumname;
  private String description;
  private String location;
  private Date date;
  private Integer uid;
  
  public Integer getAlbumid() {
      return albumid;
  }
  public void setAlbumid(Integer albumid) {
      this.albumid = albumid;
  }
  public String getAlbumname() {
      return albumname;
  }
  public void setAlbumname(String albumname) {
      this.albumname = albumname;
  }
  public String getDescription() {
      return description;
  }
  public void setDescription(String description) {
      this.description = description;
  }
  public String getLocation() {
      return location;
  }
  public void setLocation(String location) {
      this.location = location;
  }
  public Date getDate() {
      return date;
  }
  public void setDate(Date date) {
      this.date = date;
  }
  public Integer getUid() {
      return uid;
  }
  public void setUid(Integer uid) {
      this.uid = uid;
  }
  
  }
  </code></pre>
  
  <p>I am retrieving data from db and adding it to my array list like this</p>
  
  <pre><code>public ArrayList getAllAlbums(Integer uid) {
      ViewAlbum album = new  ViewAlbum();
      ArrayList&lt;ViewAlbum&gt;allAlbums = new ArrayList&lt;ViewAlbum&gt;();
      try {
          String qstring = "SELECT albumid, albumname, description, location," +
                  " date, uid FROM picvik_picture_album WHERE " +
                  "uid = '" + uid + "';";
  
          System.out.println(qstring);
          connection = com.picvik.util.MySqlConnection.getInstance().getConnection();
          ptmt = connection.prepareStatement(qstring);
          resultSet = ptmt.executeQuery();
          while(resultSet.next()) {
              //System.out.println(resultSet.getString("albumname"));
              album.setAlbumid(resultSet.getInt("albumid"));
              album.setAlbumname(resultSet.getString("albumname"));
              album.setDescription(resultSet.getString("description"));
              album.setLocation(resultSet.getString("location"));
              album.setDate(resultSet.getDate("date"));
              album.setUid(resultSet.getInt("uid"));
              allAlbums.add(album);
          }
  
          resultSet.close();
          ptmt.close();
          connection.close();
  
  
      } catch (Exception e) {
          e.printStackTrace();
      }   
      return allAlbums;
  }
  </code></pre>
  
  <p>But when I am trying to print the values stored in array list. Its always giving me the last inserted record.</p>
  
  <pre><code>&lt;div class="row"&gt;
                  &lt;div class="span10"&gt;
                      &lt;s:iterator value="allAlbums"&gt;
                          &lt;s:property value="albumname"/&gt;
                      &lt;/s:iterator&gt;   
                  &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>