Updated: Dynamic TableView Data From Database

Updated in: Aug 5, 2014 @ 12:50 by Narayan [This update is compatible with new Java 8 codes modified]

Hello, Today I’m going to show the demo of how to display the exact database data in JavaFX 2.0 from TableView. I call this TableView as Dynamic TableView because the tableview automatically manages the columns and rows.

Requirements of this demo:

Database Structure
This below give the structure of database table I used for sample.


JavaFX 2.0 SourceCode
Main GUIClass

This class consists all the GUI Components and the data are being extracted from database

Here I used ObservableList< ObservableList > ‘data’ for keeping the records so that I could add data of Rows and Columns.The above class makes a dynamic TableView extracted data from Database.

Database Connectivity Class

In above class the url,user,pass may varies according to your mysql configuration.


TableView From Database

Here you go the output depends upon the database queries.


All the source code are published in a github repository : https://github.com/privatejava/javafx-dynamic-tableview

Don’t hesitate on commenting your views.
Thanks for viewing Hava a 🙂 good day.

163 thoughts on “Updated: Dynamic TableView Data From Database”

  1. hello,
    I am getting this error it can not be string why?

    TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i+1));

  2. The below part of code never works for me, I am not getting any values in TableView for rows. I am getting only column names inside the table.

    ObservableList row = FXCollections.observableArrayList();
    for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++){
    System.out.println(row );
    //FINALLY ADDED TO TableView

  3. Nice code !!!!! You helped me so much for my exam. theres only one little unimported mistake or not solved, come on…..doesnt matter…
    nice nice nice

Leave a Reply