So I checked the other No content in TableView but it was no help.
I have a database named ledger and I want to bring my transactions into view.
void buildData(){
final ObservableList<ObservableList<String>> data = null
try{
//ResultSet
ResultSet rs = sql.getTransactions(account.getValue().toString())
/**********************************
* TABLE COLUMN ADDED DYNAMICALLY *
**********************************/
for(int i=0 ; i<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<TableColumn.CellDataFeatures<ObservableList,String>,ObservableValue<String>>(){
ObservableValue<String> call(TableColumn.CellDataFeatures<ObservableList, String> param) {
return new SimpleStringProperty(param.getValue().get(j).toString())
}
})
budgetTable.getColumns().addAll(col)
}
/********************************
* Data added to ObservableList *
********************************/
while(rs.next()){
//Iterate Row
ObservableList<String> row = FXCollections.observableArrayList()
for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++){
//Iterate Column
row.add(rs.getString(i))
}
println("Row [1] added "+row )
data?.add(row)
}
//FINALLY ADDED TO TableView
budgetTable.setItems(data)
}catch(Exception e){
e.printStackTrace()
System.out.println("Error on Building Data")
}
}
I have 5 columns in the database that do comeback and are added to the tableview. These are date, from_account, to_account, amount & notes:
mysql> show columns from ledger;
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| version | bigint(20) | NO | | 1 | |
| date | datetime | NO | | NULL | |
| notes | varchar(35) | NO | | NULL | |
| amount | double | NO | | NULL | |
| from_account | varchar(19) | NO | | NULL | |
| to_account | varchar(55) | YES | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
7 rows in set (0.45 sec)
I get no error or otherwise I would have a very good chance of solving it. At this point I don't know what the problem is. Just says "No content in table" upon build. The file is a groovy file so that's why it looks like python syntax.
Thank you in advance for your help, time and insights! Be well!