vector addElement



Hi,

I have a problem with using a Vector.

I want to store the rows of an sql query resultset in a vector.

I add the values into it in a loop.

Here is my code:

while (SQLResultSet.next()) {

// buffering one row

for(int i=0; i<fields.length; i++) {

//the row is stored in a string array
row_container[i] = SQLResultSet.getString(fields[i]);
}

buffer.addElement(row_container); // adding the string array to
the vector

}

In the row_container I store in each iteration one resultset row.


The problem is, that it seems to me, that the addElement method adds
the row_container to the end of the vector and then changes the value
of all its previous instances.

So the content of the vector (after 1,2,3,4 loops) is like:

First loop:
1 | snake | reptile

Second loop:
2 | frog | amphibian
2 | frog | amphibian

Third loop:
3 | tuna | fish
3 | tuna | fish
3 | tuna | fish

Forth loop:
4 | racoon | mammal
4 | racoon | mammal
4 | racoon | mammal
4 | racoon | mammal

Instead of:

First loop:
1 | snake | reptile

Second loop:
1 | snake | reptile
2 | frog | amphibian

Third loop:
1 | snake | reptile
2 | frog | amphibian
3 | tuna | fish

Forth loop:
1 | snake | reptile
2 | frog | amphibian
3 | tuna | fish
4 | racoon | mammal

Could you tell me how could i get the latter result?

Thx.

Best,

korcs

.



Relevant Pages

  • Re: Help Me Understand FishTales
    ... Hit the small fish targets on the front left/right. ... hit the left loop to collect a bonus. ... Put three balls into the reel to start multiball. ...
    (rec.games.pinball)
  • Re: RELENG_5 and FAST_IPSEC limits
    ... This also seems to send racoon into a hung state that we then ... >Upping the raw socket buffer sizes should permit more information to be ... >than can be reported in a single msg. ... I am pretty sure racoon was getting hung up in pfkey.c in this loop ...
    (freebsd-stable)
  • Re: Help Me Understand FishTales
    ... Hit the small fish targets on the front left/right. ... hit the left loop to collect a bonus. ...  Send the ball up the left ...
    (rec.games.pinball)
  • Re: Dry and dropper question
    ... the loop over it. ... If you get a big fish on the dry, this will kink your line more as it ... You can also lock the leader ring more firmly using a similar ... This will still slide ...
    (rec.outdoors.fishing.fly)