• 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

Vectors - please explain

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking through a textbook (Java How to program by Dietel abd Dietel) which provides some code to connect to database and then to display the database on the screen. However, I am trying to understand the code and can't understand the following methods.
From what i can see currentRow is a vector within a set of other vectors; rows. Am I right? Basically I just want to know how the vectors in this code extract work. Thanks.
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 3 uses of Vector in this code.
1. "columnHeads" Vector - This is a simple Vector that contains the column names returned in the query, i.e. each element in the Vector is a String that represents each column name. If the query returns 100 rows with 5 columns, then "columnHeads" will contain 5 elements: one for each column name.
2. "rows" Vector - This Vector is used to represent a single row of the query. Each element in this Vector is another Vector returned by the getNextRow() method, i.e. this is a Vector of Vectors. If the query returns 100 rows with 5 columns, then "rows" will contain 100 elements: one for each "row" returned by the query.
3. "currentRow" Vector - This Vector is returned by the getNextRow() method. Each element in this Vector is the field value for a specific row and column of the query. As each row in the query is processed, the specific field values for that single row are added as elements of this Vector. If the query returns 100 rows with 5 columns, then "currentRow" will contain 5 elements: one for each field value. Each "currentRow" Vector gets placed into the "rows" Vector above.
Hopefully that helps a little bit.
 
reply
    Bookmark Topic Watch Topic
  • New Topic