title: Javafx update database with tableview
body: <p>I have create a script that will create and populate data to tableview (i've used scene builder for tableview). it's column is dynamic depending on the number of columns of mysql table. But I can't find any solutions on how to edit/insert data to tableview and automatically update the MySQL table.</p>
  
  <p>here is my code  for dynamic columns and populating data from database to it. By the way, database table I am using has 50 columns.</p>
  
  <pre><code>data = FXCollections.observableArrayList();
      try {
          c = DBConnect.connect();
          //SQL FOR SELECTING ALL OF CUSTOMER
          String SQL = "SELECT * from CAM_ODS_TIMESHEET_RAW_MOD";
          //ResultSet
          ResultSet rs = c.createStatement().executeQuery(SQL);
  
          /**
           * ********************************
           * TABLE COLUMN ADDED DYNAMICALLY * 
           * ********************************
           */
          for (int i = 0; i &lt; rs.getMetaData().getColumnCount(); i++) {
              //We are using non property style for making dynamic table
              final int j = i;
              TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i + 1));
              col.setCellValueFactory(new Callback&lt;CellDataFeatures&lt;ObservableList, String&gt;, ObservableValue&lt;String&gt;&gt;() {
                  public ObservableValue&lt;String&gt; call(CellDataFeatures&lt;ObservableList, String&gt; param) {
                      return new SimpleStringProperty(param.getValue().get(j).toString());
                  }
              });
  
              tableview.getColumns().addAll(col);
  
              System.out.println("Column [" + i + "] ");
          }
  
          /**
           * ******************************
           * Data added to ObservableList * 
           * ******************************
           */
          while (rs.next()) {
              //Iterate Row
              ObservableList&lt;String&gt; row = FXCollections.observableArrayList();
              for (int i = 1; i &lt;= rs.getMetaData().getColumnCount(); i++) {
                  //Iterate Column
                  if (rs.getString(i) == null) {
                      row.add("");
                  } else {
                      row.add(rs.getString(i));
                  }
              }
              System.out.println("Row [1] added " + row);
              data.add(row);
  
          }
  
          //FINALLY ADDED TO TableView
          tableview.setItems(data);
      } catch (Exception e) {
          e.printStackTrace();
          System.out.println("Error on Building Data");
      }
  </code></pre>
  
  <p>I've also seen multiple examples that uses Model like Person class etc but I am wondering how can I use that for multiple columns like 50 columns</p>
  
  <p>Thank you in advance for your help! :)</p>