title: javafx combobox selectionmodel is not consistant
body: <p>I am creating javafx application where I insert selected items of combobox which are also populated from database to another table of database but problem is that combobox's selection model is not working consistent some time it is giving item which are selected but some it sends null value to database </p>
  
  <p>Code:</p>
  
  <pre><code>package application;
  
  import java.net.URL;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.ResourceBundle;
  import org.controlsfx.control.textfield.TextFields;
  import javafx.collections.FXCollections;
  import javafx.collections.ObservableList;
  import javafx.event.ActionEvent;
  import javafx.fxml.FXML;
  import javafx.fxml.Initializable;
  import javafx.scene.control.TableView;
  import javafx.scene.control.TextField;
  import javafx.scene.control.Alert;
  import javafx.scene.control.Alert.AlertType;
  import javafx.scene.control.cell.PropertyValueFactory;
  import javafx.scene.control.ComboBox;
  import javafx.scene.control.DatePicker;
  import javafx.scene.control.TableColumn;
  
  public class EntryFormController implements Initializable {
  
  Connection connection = SqliteConnection.Connector();
  PreparedStatement preparedStatement = null;
  ResultSet rs = null;
  
  ObservableList&lt;String&gt; cBoxList1 = FXCollections.observableArrayList();
  ObservableList&lt;String&gt; cBoxList2 = FXCollections.observableArrayList();
  
  
  @FXML
  private ComboBox&lt;String&gt; TruckNo;
  @FXML
  private ComboBox&lt;String&gt; exp1;
  @FXML
  private ComboBox&lt;String&gt; exp2;
  
  @FXML
  private void addButton(ActionEvent e) {
      String query = "insert into entry (Truck,Expense)values(?,?),(?,?) ";
  
      try {
          preparedStatement = connection.prepareStatement(query);
          preparedStatement.setString
          (2,TruckNo.getSelectionModel().getSelectedItem());
          preparedStatement.setString
          (3, exp1.getSelectionModel().getSelectedItem());
          TruckNo.getSelectionModel().getSelectedItem());
          preparedStatement.setString
          (9,exp2.getSelectionModel().getSelectedItem());
  
          preparedStatement.execute();
  
          TruckNo.setValue(null);
          TruckNo.valueProperty().set(null);
          exp1.setValue(null);
          exp1.valueProperty().set(null);
          exp2.setValue(null);
          exp2.valueProperty().set(null);
  
          preparedStatement.close();
  
  
      } catch (SQLException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
      }
  }
  
  @Override
  public void initialize(URL location, ResourceBundle resources) {
      // TODO Auto-generated method stub
  
  
      exp1.setItems(cBoxList1);
      exp1.setEditable(true);
      loadDatabaseDataCombo1();
      exp2.setItems(cBoxList2);
      exp2.setEditable(true);     
      TruckNo.setItems(trkList);
      TruckNo.setEditable(true);
      loadDatabaseDataCombo6();
  
      TextFields.bindAutoCompletion(exp1.getEditor(), exp1.getItems());
      TextFields.bindAutoCompletion(exp2.getEditor(), exp2.getItems());
  TextFields.bindAutoCompletion(TruckNo.getEditor(),TruckNo.getItems());
  
  }
  
  private void loadDatabaseDataCombo6() {
      String query = "select * from Truck";
      try {
          preparedStatement = connection.prepareStatement(query);
          rs = preparedStatement.executeQuery();
  
          while (rs.next()) {
              trkList.add(rs.getString("TruckNo"));
          }
  
      } catch (SQLException e) {
          e.printStackTrace();
      }
  }
  
  }
  
  
  private void loadDatabaseDataCombo2() {
      String query = "select * from Expense";
      try {
          preparedStatement = connection.prepareStatement(query);
          rs = preparedStatement.executeQuery();
  
          while (rs.next()) {
              cBoxList2.add(rs.getString("name"));
          }
  
      } catch (SQLException e) {
          e.printStackTrace();
      }
  
  }
  
  private void loadDatabaseDataCombo1() {
      String query = "select * from Expense";
      try {
          preparedStatement = connection.prepareStatement(query);
          rs = preparedStatement.executeQuery();
  
          while (rs.next()) {
              cBoxList1.add(rs.getString("name"));
          }
  
      } catch (SQLException e) {
          e.printStackTrace();
      }
  
  }
  
  }
  </code></pre>