GeeCON Prague 2014*
The moose likes JDBC and the fly likes creating a front end for a query which Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "creating a front end for a query which" Watch "creating a front end for a query which" New topic
Author

creating a front end for a query which

Max Vandenburg
Ranch Hand

Joined: Mar 09, 2006
Posts: 51
Hi All,

This is my first ever post. so here we go...
Im trying to get "names of customer" from a "customer" table and displayed them in a GUI. where it will display the first record, and when i click the "next" button it will display the next record...

what i have done:
- i've created a simple testing GUI which has a JLabel, 2 JButton (for Previous and Next button), and a JTextField to display the customer name itself.

- i've also made a connection to the database, i.e. create connection, register the driver, create resultset, metadata etc.

this is where im stuck:
- so far by using this statement i can print out the list of names


Im guessing, instead of printing this values to the console, i want them to be stored in some kind of array... so i would have to create an String array beforehand and store it there... the problem is that i need to know what the arraysize (i.e. the number of records is in the table) before i can use the array. so get the size of the array,i would have to go thru the same method above but instead of printing it out, i add an "int" counter which i, then use for my array... as you can see this method is messy...

anyone got any idea/best practices on how to approach this problem? basically i want to the result from my query somewhere, where later, i can use display them in my JTextField?
[ April 04, 2006: Message edited by: Bear Bibeault ]

MV
Max Vandenburg
Ranch Hand

Joined: Mar 09, 2006
Posts: 51
Ok, after some research i think the answer to this is the Vector Class...
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Originally posted by Firman Drage:
Ok, after some research i think the answer to this is the Vector Class...



... or any of the other Collection types, using one that has ordering if you need an ordered list.
 
GeeCON Prague 2014
 
subject: creating a front end for a query which