aspose file tools*
The moose likes Java in General and the fly likes Vector of Vectors trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

Vector of Vectors trouble

Padraig Joseph
Greenhorn

Joined: May 07, 2002
Posts: 13
I'm having problems with the code below. Everything goes fine until I try to add vctTemp to vctFootballRecord. Instead of just appending the new vector element to the end of the vector, it seems to replace every existing element in the vector with the new one as well. What's going on?
String football = "SELECT * FROM tblGAAFootball WHERE year >= 1997";
try{
statement = connection.createStatement();
resultSetF = statement.executeQuery(football);
while (resultSetF.next()) {
vctFootballList.removeAllElements();
vctTemp.removeAllElements();
String nDateF = resultSetF.getString("date");
vctFootballList.addElement(nDateF);
String nMonthF = resultSetF.getString("month");
vctFootballList.addElement(nMonthF);
String nYearF = resultSetF.getString("year");
vctFootballList.addElement(nYearF);
String szTeam1F = resultSetF.getString("team1");
vctFootballList.addElement(szTeam1F);
String szTeam2F = resultSetF.getString("team2");
vctFootballList.addElement(szTeam2F);
String nTeam1GoalsF = resultSetF.getString("team1Goals");
vctFootballList.addElement(nTeam1GoalsF);
String nTeam1PointsF = resultSetF.getString("team1Points");
vctFootballList.addElement(nTeam1PointsF);
String nTeam2GoalsF = resultSetF.getString("team2Goals");
vctFootballList.addElement(nTeam2GoalsF);
String nTeam2PointsF = resultSetF.getString("team2Points");
vctFootballList.addElement(nTeam2PointsF);
String szNeutralF = resultSetF.getString("neutral");
vctFootballList.addElement(szNeutralF);
String szCompetitionF = resultSetF.getString("competition");
vctFootballList.addElement(szCompetitionF);
String szStageF = resultSetF.getString("stage");
vctFootballList.addElement(szStageF);
for(int i=0; i<12; i++)
{
vctTemp.addElement(vctFootballList.elementAt(i));
}

vctFootballRecord.add(vctTemp);
}
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Please don't cross post, it just makes it difficult to follow a conversation. Now, back in the beginners forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Vector of Vectors trouble