I've made a class called Animal with the following constructor:
Animal(int id, String name, String kind)
Now I get data from a database and want to store this data in a Vector().
This goes like this:
Vector list = new Vector();
Statement st = connection.createStatement();
String query = "SELECT * FROM ANIMALS";
ResultSet rs = st.executeQuery(query);
while (rs.next()) {
int id = rs.getInt("animalId");
String name = rs.getString("name");
String kind = rs.getString("kind");
Animal animal = new Animal(id, name, kind);
list.add(animal);
}
Now when I want to get the data from the Vector, and I print it on the screen, I get for every row in the Vector the same output. Something like this:
Fish blub Goldfish
Fish blub Goldfish
Fish blub Goldfish
etc.
Does somebody know how I can get this right??