Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

*Urgent* Display SQL search results in a tabular form

 
King-Chieh Wang
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic