title: Java Swing jComboBox not filling from Database
body: <p>So I am working on a task force schedule for my mothers charity project. The aim is to check in the volunteers, display the roster for times and what station they are at. I have successfully built a login form, that pulls the data from the database and verify if your entered username (from dropdown) and password are correct. I have this method (NB: for the login form, it works and is not the problem) to fill the username dropdown called <code>'cbxUsername'</code> which is called inside the main method when the window loads:</p>
  
  <pre><code>public void loginToProgram() throws Exception{
          user = (String) cbxUsername.getSelectedItem();
          if(user == "Please select a username"){
              JOptionPane.showMessageDialog(null, "Sorry, You need to select a username to continue");
          }else if(txtPassword.getText().length() == 0){
              JOptionPane.showMessageDialog(null, "Sorry, You need to enter a password to continue");
          } else {
              checkAuth();
          }
  
  }
  </code></pre>
  
  <p>and then this method is refered to above, this is the checkAuth() method:</p>
  
  <pre><code>public void checkAuth() throws Exception{
      Class.forName("com.mysql.jdbc.Driver");
  
      Connection con = DriverManager.getConnection("jdbc:mysql://localhost/crm", "root", "t00rt00r");
      PreparedStatement statement = (PreparedStatement) con.prepareStatement("SELECT `password` FROM users WHERE `username` = '"+ user +"'");
      ResultSet result = statement.executeQuery();
      if(result.next() != false){
          pass = result.getString(1);
      }
      if(txtPassword.getText().equalsIgnoreCase(pass)){
          //JOptionPane.showMessageDialog(null, "Worked");
          CheckIn chk =  new CheckIn();
  
          chk.setVisible(true);
      } else {
          JOptionPane.showMessageDialog(null, "Sorry, wrong password");
      }
  }
  </code></pre>
  
  <p>Now I have copied the first code (the method 'loginToProgram()') and altered it abit.</p>
  
  <p>Now I have a new window called 'CheckIn', with a jComboBox called 'cbxCIFirstName'. The code to fill up this combobox is:</p>
  
  <pre><code>public static void fillFirstNameCombobox() throws Exception{
      Class.forName("com.mysql.jdbc.Driver");
  
      Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/crm", "root", "t00rt00r");
      PreparedStatement statement = (PreparedStatement) con.prepareStatement("SELECT `first_name` FROM `volunteers`");
      ResultSet result = statement.executeQuery();
      cbxCIFirstName.setToolTipText("Select a first name");
      cbxCIFirstName.setEditable(true);
      cbxCIFirstName.addItem("Please Select a first name");
      while(result.next()){
          cbxCILastName.addItem(result.getString(1));
      }
      System.out.println(result.getString(1));
  }
  </code></pre>
  
  <p>Please note: I put the <code>System.out.println(result.getString(1));</code> there just to see if it was coming through in the console, and it is NOT coming through on the console. What am I doing wrong? Here is my Main method:</p>
  
  <pre><code>public static void main(String[] args) throws Exception{
  
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  fillFirstNameCombobox();
                  CheckIn frame = new CheckIn();
                  frame.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  </code></pre>
  
  <p>Any suggestions will be greatly appreciated, any comments, guides, tutorials or anything I will take into consideration and try!</p>
  
  <p>Thanks for your time, reading this post and thanks in advance for your answers,
  Josh.</p>