title: Java - Using two values from a database in a combobox
body: <p>I'm developing a simple Java program to retrieve info from a database and show it to the user, I want to take the info of certain tables and add it to a combobox (Or whatever works) but still be able to get the id back when I select an option.</p>
  
  <p>For example let's say I have a table like this</p>
  
  <pre><code>people table
  
  id  name
  ---------
  1   Roger
  2   Mike
  3   Bob
  </code></pre>
  
  <p>What I want to do is retrieve all the names to show them in a combobox, and if I choose let's say 'Mike' from the options list, I want the program to be able to give me back the id for Mike so I can use it in another select. Is it possible? If not, is there a better way to do what I want to do without having to use the name in a select? I already have a method to get the info I need and put it into a hashmap, I don't know if I can use it somehow.</p>
  
  <p>Also, another related question, what is a better practice for this kind of programs? To retrieve info from a database and have it available all the time without having to read the database again? Or to read the database only for the info I need at the moment and do it every time?</p>
  
  <p>Edit:
  I'm using Swing GUI</p>