This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

*Urgent* Display SQL search results in a tabular form

King-Chieh Wang

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,
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...
Have you checked out Aspose?
subject: *Urgent* Display SQL search results in a tabular form
It's not a secret anymore!