wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes *Urgent*  Display SQL search results in a tabular form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "*Urgent*  Display SQL search results in a tabular form" Watch "*Urgent*  Display SQL search results in a tabular form" New topic
Author

*Urgent* Display SQL search results in a tabular form

King-Chieh Wang
Greenhorn

Joined: Jan 26, 2004
Posts: 24
Hey guys!
I have a huge question. I am implementing a simple UI that the user can input some query for a DVD database, and the UI displays the result in a rather neat tabular form. How can I do that?
What I have now, is just a simple from-the-book blank search fields that allows the user to type in keywords to search the DB (a SQL DB). After that, I am pretty much clueless, anyone shed some (detail or abstract) lights?
Thanks in advance,
Jack
maggie woo
Ranch Hand

Joined: Dec 18, 2003
Posts: 35
Assuming you know how to get the data from the database, and get each individual data item (each row, each column)....
Use a JTable, and a custom TableModel. For starters, extend the AbstractTableModel. See the API--it'll tell you what methods you have to define for the JTable to function. If your queries generally return short sets of data, just iterate over the entire set to build the underlying data model, then put that model on the JTable, then put that JTable in a JScrollPane, etc. and see what happens.
You'll eventually probably want to override a few other things, but for now, you probably want to see your data in a table before you care about the little things...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: *Urgent* Display SQL search results in a tabular form