DataTables & Tags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SammyB
    Recognized Expert Contributor
    • Mar 2007
    • 807

    DataTables & Tags

    I am working on a project that does a query, displays the data, and then when the user selects an item, updates the database. I am implementing this as follows
    1. Creating an object, call it DD, whose properties correspond to the fields returned by the query
    2. Overloading the toString method of DD to return the portions that I want to display.
    3. Create a generic list, ArrayList<DD> DDlist, and for each row returned by the query, add a DD object to DDlist.
    4. Create a JList, DDListBox, and populate it from DDList:
      For (DD d : DDList) DDListBox.addIt em(d.toString() ;
    5. When the user clicks on an item, pop-up a JOptionPane and based on the user's response, set a flag and/or copy the data into another table.
    Might work, but I have two questions:
    1. My database is small, but has lots of tables. If I were in the DotNet world, I would place the results of some large join of all of the tables into a DotNet structure called a DataTable. Then I could just do SQL queries and updates on that DataTable. Is there an equivalent to the DataTable in Java?
    2. Again in the DotNet world, all of the controls have tag properties that can hold any object. So, if I was creating a ListBox in DotNet for the DD objects, when I added d.toString as a ListBox item, I would also add d to the item's tag, so I would have all of the information available. Is there a way to do this in Java? In other words, some sort of way to make controls more data aware?
    Is there hope for this old VB programmer?
Working...