mardi 13 novembre 2018

Insert data into database from TableView CheckBox JavaFX

I have a tableView in JavaFX (for recording attendance of students) which has a column of checkBox (called "Present") which can be checked by user. My database has a column called "classesAttended" which stores total no. of classes attended by students.

My approach is:

Database Table name: "student"

Database Column Name: "classesAttended"

TableView Column Name: "attendance"


    {

    TableView<Student> tables = new TableView<Student>();

    TableColumn<Student, Boolean> attendance = new TableColumn<Student,Boolean>();
    }


    String query="UPDATE student SET classesAttended = classesAttended+1";

    pst = conn.prepareStatement(query);

    for(TableRow tableRow: tables.getRows()){ 

        string input =    tables.get(i).getAttendanceColumn().toString();        

        if(input = "true"){

            pst.execute;

        }

    }


So I want to increment the value of "classesAttended" for student whose "Present" column is checked. Please suggest me how can I do it.......

Thanks in Advance




Aucun commentaire:

Enregistrer un commentaire