title: Populate a tableview using database in JavaFX
body: <p>I'm starting to learn javaFX and I need to populate a table with data from my database. I've read a lot of code online, but I haven't found what I was looking for. I read <a href="http://pastebin.com/S0Fg9jK8">this</a> but I don't know how to implement that last function. I read some other code to do that and so far this is some of my code: </p>
  
  <pre><code>@FXML private TableView&lt;User&gt; table;
  @FXML private TableColumn&lt;User, String&gt; nameCol;
  @FXML private TableColumn&lt;User, String&gt; emailCol;
  private ObservableList&lt;User&gt; data;
  
  public void initialize(URL location, ResourceBundle resources) {
      nameCol.setCellValueFactory(new PropertyValueFactory(“name”));
      emailCol.setCellValueFactory(new PropertyValueFactory(“email”));
      buildData();
  }
  public void buildData() {
          Connection connect = new Connection();
          Statement st = connect.Connect();
          data = FXCollections.observableArrayList();
          try {
              ResultSet rs = st.executeQuery("SELECT * FROM USER");
               while (rs.next()) {
                  ObservableList&lt;User&gt; row = FXCollections.observableArrayList();
                  for (int i = 1; i &lt;= rs.getMetaData().getColumnCount(); i++) {
                      row.add(rs.getString(i));
                      System.out.println(row);
                  }
                  data.add(pol);
              }
              tabla.setItems(data);          
          } catch (SQLException ex) {
              JOptionPane.showMessageDialog(null, ex);
          }
  }
  </code></pre>
  
  <p>I hope you can help me</p>