How to use the return value of call method of Task class in Javafx

Viewed 21760

I am using Task class to run background task in javafx application to fetch the data from the database.

public class CustomTask extends Task<ObservableList<ObservableList>> {
    TableView tableview;
    ObservableList<ObservableList> data;

    public CustomTask(TableView tableview) {
        this.tableview = tableview;
    }

    @Override
    protected ObservableList<ObservableList> call() throws Exception {
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date = new Date();
        String SQL = "SELECT * from sell where Date='" + dateFormat.format(date) + "'";
        ResultSet rs = DBConnect.getResultSet(SQL);
        data = DBConnect.generateListDateFromTable(rs, true);

        return data;
    }
}    

How to use the data object.

2 Answers
Related