• 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:
  • 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

get the result set in to the vector

 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i,am trying to get ther databse records into a vector .....how should i goabout it .....help needed
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector rs = new Vector();
rs.add(resultset.next());
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think Adrian's solution will work. ResultSet.next returns a boolean indicating whether there is another record in the ResultSet. ResultSet.next does not return the next record in the ResultSet. This solution will not compile because Vector.add expects an Object and ResultSet.next returns a primitive.
As far as I know there's no quick and easy way to do what you want. ResultSets can be a pain.
What I would do is write a class that has instance variables for each column in the table. Then step through the resultset with a while loop. In the loop perform these three steps. 1) Create an object (of the class you wrote) for the current row. 2) Transfer the data in the row from the ResultSet to the object (using ResultSet.getXXX). 3) Add the object to the vector (using Vector.add).
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[This message has been edited by Thomas Paul (edited February 13, 2001).]
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For each row of record read, loop through the columns adding them to an array, then add the array of columns to your vector.
Bosun
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that's what my code does, doesn't it?
 
Hot dog! An advertiser loves us THIS much:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic