[Solved] javafx Tableview not showing data from database


In the getRoom.rmview method you fill assign the fields of the rmview instance again and again, but you never modify the roomlist of rmview is never modified; it remains empty. Since you use roomlist in the TableView, there is no data to show.

You should instead add a new element for every row the database query returns:

// remove data previously in the list
rmList.roomlist.clear();

while (rs.next()){
    rmList.roomlist.add(new ListRoom(rs.getString(1),
                                     rs.getString(2),
                                     rs.getString(3),
                                     rs.getString(4),
                                     rs.getString(5)));
}

Furthermore I recommend adhering to the naming conventions. Especially the part about abreviations since this makes your code hard to read for others. Furthermore object is a bad choice as name for a type parameter. It leads to confusion and usually single uppercase letters are used for type parameters.

Also the purpose of the rmlist class is unclear. It contains the same fields as ListRoom, but also contains a list where you want the data to actually be stored. Why do you need those fields? Do you need rmlist at all or could it just be replaced with ObservableList<ListRoom>?

1

solved javafx Tableview not showing data from database