This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Vectors - please explain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Vectors - please explain" Watch "Vectors - please explain" New topic

Vectors - please explain

Naf Rash
Ranch Hand

Joined: Feb 19, 2004
Posts: 85
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

Joined: Sep 13, 2002
Posts: 331
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.

Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
I agree. Here's the link:
subject: Vectors - please explain
Similar Threads
A simple Question -need help!!!!
My JTable is a bit confused
JTable type yes/no
JTable refreshing problem
JTable & JDBC