File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vectors - please explain

 
Naf Rash
Ranch Hand
Posts: 85
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Blake Minghelli
Ranch Hand
Posts: 331
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic