title: How do I add multiple items from a jcombobox from a database in ms access
body: <pre><code>import java.sql.*;
  import java.awt.*;
  
  import javax.swing.*;
  
  import java.awt.event.*;
  
  class ComboExample {
   Connection con;
   Statement st;
   ResultSet rs;
  
  ComboExample() {
      JFrame f = new JFrame();
      f.getContentPane().setLayout(null);
      final JComboBox combo = new JComboBox();
          try {
               String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
               Class.forName(driver);
               String db = "jdbc:odbc:TTracking";
               con = DriverManager.getConnection(db);
  
               // Getting database info
               DatabaseMetaData meta = con.getMetaData();
               System.out.println("Server name: " +
  meta.getDatabaseProductName());
               System.out.println("Server version: " +
  meta.getDatabaseProductVersion());
               System.out.println("");
  
               System.out.println("Creating statement...");
                st = con.createStatement();
                String sql = "SELECT Trailer FROM TrailerLocationMaster";
                ResultSet rs = st.executeQuery(sql);
                      while (rs.next()) {
          String trailer = rs.getString("Trailer");
          combo.addItem(trailer);
          System.out.println(rs.getString("Trailer"));
          combo.setVisible(true);
          }
          }
           catch (Exception ex) {
              }
  
      combo.setBounds(20, 50, 150, 20);
      f.add(combo);
      f.setSize(400, 200);
      f.setVisible(true);
  
  }
  
  
  
  
  
  
  public static void main(String[] args) {
      ComboExample c = new ComboExample();
      }
  }
  </code></pre>
  
  <p>The combo-box displays correctly, but only one item from the database table  appears why is that? and how do I allow multiple items to be in jcombobox from database? Also why does it always complain with and advises suppress warnings?</p>