• Post Reply 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Vector Values

 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a vector called v1 and I am loading values to the vector from a resultset.

--while ((getDet_hasData)&&(Repeat1__numRows-- != 0)) {
--v1.addElement(getDet.getObject("EMAIL")+",");
------- some code
)
where getDet is name of the resultset.

I am iterating the loop
Object vect;
String str = "";

for(int i=0;i<v1.size();i++) {
vect = v1.get(i).toString();
str = (String)vect;
bean.setStrValues(4,str);

}
setStrValues is a method in the bean and passing the value.

My problem is I am getting only the last value in my method, after the for loop I have other code to process. Since I am taking the value in the vector and I am iterating I should get all the values, rather than the last values.

What could be the problem and how can I solve it. Please help me

Any help is highy appreciated.

Thanks

Cosmos
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like it should work, although it appears that the code could use some simplification. Send the other code if possible; use the UBB Code tags to help make it more readable.

-Jeff-
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're calling the setStr method with each value from the Vector, but each one replaces the prior value so you only see the last one. Maybe you could build up a single string with all the values in your loop and call setStr after the loop.

You'll have to work out the spaces and commas and such to make allValues look nice, but something like that oughtta work.
 
Pol Appan
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to everyone for pointing out the problem.

I will try.

Thanks

Cosmos
reply
    Bookmark Topic Watch Topic
  • New Topic