I have an ArrayList in Java to store information retrieved from a MySQL database. The problem is when I am adding the objects from the db to the ArrayList it is overwriting the list and I am ending up with a list full of only the last record. Here is the code:
ArrayList <Profile> dbProfile = new ArrayList<Profile>();
while (resultSet.next())
{
Profile profile = new Profile();
profile.name = (resultSet.getString("Name"));
System.out.println(profile.name);
profile.birthday = (resultSet.getDate("Birthday"));
profile.weight = (resultSet.getBigDecimal("Weight"));
profile.gender = (resultSet.getBoolean("Gender"));
profile.classType = (resultSet.getString("Class"));
profile.race = (resultSet.getString("Race"));
profile.img = (resultSet.getBlob("Img"));
dbProfile.add(profile);
model.addElement(profile.name);
}