从TableView CheckBox JavaFX将数据插入数据库

时间:2018-11-13 13:33:30

标签: mysql javafx checkbox tableview

我在JavaFX中有一个tableView(用于记录学生的出勤情况),其中有一列checkBox(称为“出勤”),可由用户检查。我的数据库有一个名为“ classesAttended”的列,它存储总数。学生参加的课程。

我的方法是:

数据库表名:“学生”

数据库列名:“参加的类”

TableView 列名:“出勤”


    {

    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;

        }

    }

因此,对于要检查“出勤”列的学生,我想增加其“ classesAttended”的值。请建议我该怎么做....

预先感谢

1 个答案:

答案 0 :(得分:0)

查询中需要一个where子句,以将tableView上的行与数据库中的记录进行匹配。

相关问题