//对于处理数据库的方法list,这些要在已经把数据拿出来储存的条件下
ArrayList<Snose> snoseArr=new ArrayList<>();//;链接相应的类,new一个
ArrayList<Courses> courseArr=new ArrayList<>();
ArrayList<Students> studentArr=new ArrayList<>();
while (resultSet.next()) {//对一个表进行因此查获
Snose snose=new Snose();
snose.setSno(resultSet.getString("sno"));
snose.setCsno(resultSet.getString("csno"));
snose.setScore(resultSet.getDouble("score"));
snoseArr.add(snose);
}

preparedStatement = connection.prepareStatement("select * from courses");
resultSet = preparedStatement.executeQuery();
resultSet.last();
while (resultSet.next()){
Courses courses=new Courses();
courses.setCsno(resultSet.getString("csno"));
courses.setCourse(resultSet.getString("course"));
courseArr.add(courses);
}

preparedStatement= connection.prepareStatement("select * from students");
resultSet = preparedStatement.executeQuery();
resultSet.last();
while (resultSet.next()){
Students student=new Students();
student.setName(resultSet.getString("name"));
student.setSno(resultSet.getString("sno"));
student.setAcademy(resultSet.getString("academy"));
student.setSex(resultSet.getString("sex"));
student.setConnect(resultSet.getInt("connect"));
studentArr.add(student);
}
preparedStatement.close();
resultSet.close();
Scanner in=new Scanner(System.in);
//增加
snoseArr.add(new Snose("202030133010","2020111",89));
//删除
System.out.println("请输入要删除的学生学号:");
String delSno=in.nextLine();
for(int i=0;i<snoseArr.size();i++){//删除成绩所在类表数据
if(delSno.equals(snoseArr.get(i).getSno())){
snoseArr.remove(i);
}
}
for(int i=0;i<snoseArr.size();i++){//删除学生信息所在数据表
if(delSno.equals(studentArr.get(i).getSno())){
studentArr.remove(i);
}
}
//修改
System.out.println("请输入要删除的学生学号:");
String reSno=in.nextLine();
System.out.println("请输入要修改的课程号:");
String reCsno=in.nextLine();
System.out.println("请输入要修改的成绩:");
double reScore=in.nextDouble();
for(int i=0;i<snoseArr.size();i++){
if(reSno.equals(snoseArr.get(i).getSno())&&reCsno.equals(snoseArr.get(i).getCsno())){//找到对应的成绩
snoseArr.get(i).setScore(reScore);//修改成绩
System.out.println("修改结果:"+snoseArr.get(i).getScore());//检测修改结果
}
}