从tableview checkbox javafx将数据插入数据库

t5zmwmid  于 2021-06-18  发布在  Mysql
关注(0)|答案(1)|浏览(304)

我在javafx中有一个tableview(用于记录学生的出勤情况),其中有一列checkbox(称为“出勤”),用户可以对其进行检查。我的数据库有一个名为“classesattended”的列,其中存储了学生上课的总数。
我的方法是:
数据库表名:“student”
数据库列名:“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”的值。请告诉我怎么做。。。。。。。
提前谢谢

c9x0cxw0

c9x0cxw01#

你需要一个 where 子句将表视图上的行与数据库中的记录相匹配。

相关问题