title: java - retrieving data from database and display using JcomboBox
body: <p>I would like to be able to select a data from database and display it using the comboBox. </p>
  
  <p>I have the following code but it does not display the data in the comboBox. I do realize there is codes missing to display the data and my SQL statement is not correct. I am just not sure what I can do any advise is appreciated.   </p>
  
  <p>try {
                      Statement st = db.con.createStatement();
                      ResultSet rs = st.executeQuery("SELECT Name, Size, Price FROM item WHERE Name=" + comboBox_1.getToolkit());</p>
  
  <pre><code>                JOptionPane.showMessageDialog(frame, "displayed");
  
                  while (rs.next()) {
                      String name  = rs.getString("Name");
                      String size  = rs.getString("size");
                      String price  = rs.getString("price");
                      textArea_Name.append(name);
                      textArea_size.append(size);
                      textArea_price.append(price);
                      comboBox_1.addItem(rs.getString("Name"));
                      comboBox_1.getSelectedItem();
  
                  }}              
  
  
                   catch (SQLException e ) {
                      System.out.println("user not added");
                      e.printStackTrace();
                   }              
  
              }
          });
  </code></pre>