Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Vector of Vectors trouble

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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);
}
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please don't cross post, it just makes it difficult to follow a conversation. Now, back in the beginners forum...
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic