This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
To save the contents of a resultset rs into arraylist result. However, each result.add() overwrites all previous entries with the new one. So I get an arraylist filled with the last record pulled from the db. Why? If I only add() one value, such as add(dbrows), it works fine.
You problem is not with ArrayList's add method, its with how you use your dbrows Object array. List.add() just adds an object in the next position in the List. You create one object and add it repeatedly to the list. You need to add different dbrows objects to the list. Otherwise (as you are seeing) every time you change its value, you change it for every occurance in the List.