I am wondering how can I retrieve data from a mysql database into a tableview which is into a fxml file. I must retrieve the data and place it into a tableview which is loca
AFAIK, you cannot retrieve and display the data from DB in FXML file, and make the tableview cells editable in FXML file. Even though it was possible (maybe partially through custom Builder
and BuilderFactory
), it is not recommended to do that in a sense of MVC. Please read about Why Use FXML and its benefits first. Still you can define some basic data structures in FXML file if it is so necessary, see Introduction to FXML.
So do your non-view related tasks in a initialize()
method of the controller, namely retrieve data and set the items of the tableview. Customize the cell factories of the table columns to support editing and so on.