0


mysql数据库学生成绩管理系统

学生成绩管理系统课程设计

需求分析

1 信息需求
对学校而言,学生成绩管理是管理工作中重要的一环,但是高校学生的成绩管理工作量大、繁杂,人工处理非常困难。因此,借助于强大计算机的处理能力,能够把人从繁重的成绩管理工作中解脱出来,并且更加准确、安全、清晰的管理环境。

2 功能需求
能够进行数据库的数据定义、数据操纵、数据控制等处理功能。具体功能应包括:可提供课程安排、课程成绩数据的添加、插入、删除、更新、查询,学生及教职工基本信息查询的功能。

3 安全性与完整性要求
对于学生成绩管理系统数据库来讲,由于其主要数据是学生成绩,只能由本人以及所教老师及教务处知道,因此做好数据安全性是重中之重。另外,要求所有在校学生的信息都要录入其中,并且要设计好个别情况。

E-R图

一位学生会被多位老师教导,一位老师会教导多位学生,所有学生与教师之间是多对多(m:n)的关系;
一位学生可能会选修多门课程,一门课程会被多位学生选修,所以学生与课程之间是多对多(m:n)的关系;
一位学生会有多项成绩(具体指某学生一门课程的分数),一项成绩仅被一位学生拥有,所以学生与成绩是一对多(1:n)的关系;
一位教师会讲授多门课程,一门课程会被一位教师讲授,所以教师与课程的关系是一对多(1:n)的关系;
一门课程拥有多项成绩,一项成绩仅被一门课程拥有,所以课程与成绩的关系是一对多(1:n)的关系;
学生(学号、姓名、班级、性别、专业、出生日期、学分);
老师(教师编号、姓名、学院);
课程(课程编号、教师编号、课程名称、课程学分);
成绩(学号、课程编号、分数);
在这里插入图片描述

逻辑关系

根据题目要求可以简化成三个表:
在这里插入图片描述

1.student 表:学号(sno)、姓名(sname)、性别(ssex)、专业(sdept),此为联系“student表”所对应的关系模式,学号为该关系的候选码,满足第三范式。

2.course表:课程编号(cno)、教师(cteacher)、课程名称(cname)、先修课课程号(cpno)、学分(ccredit),此为联系“course表”所对应的关系模式,课程编号和教师编号为该关系的候选码,满足第三范式。

3.sc表:学号(sno)、课程编号(cno)、分数(grade),此为联系“sc表”所对应的关系模式,学号和课程编号为该关系的候选码,满足第三范式。

物理设计和实施

创建course表
属性依次为:课程号、课程名、先修课课程号、学分、教师
主键为课程号
在这里插入图片描述

在这里插入图片描述

创建student表
属性依次为:学号、姓名、性别、年龄、所在系系名
主键为学号
在这里插入图片描述
sdept char(15) null勾选
在这里插入图片描述
注意学号不要写重复,会报错

创建sc表,表示选课关系
属性依次为学号、课程号、分数
主键为学号、课程号
在这里插入图片描述
在这里插入图片描述
数据库链接到idea
在这里插入图片描述
idea没有database的下载:
File+settings+editor+plugins+database navigator+apply+ok
出现感叹号:进connection+properties+serverTimezone+Asia/Shanghai+test connection

创建包、Add、Del、Update、Sel

主代码再最后面

AddC

/*
AddC
*/packagesc;importjava.awt.*;importjavax.swing.*;importjava.sql.*;importjava.awt.event.*;publicclassAddCextendsJPanelimplementsActionListener{JTextField 课程号,课程名,先修课课程号,学分;JButton 录入;publicAddC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        课程号=newJTextField(12);
        课程名=newJTextField(12);
        先修课课程号=newJTextField(12);
        学分=newJTextField(12);
        录入=newJButton("录入");
        录入.addActionListener(this);Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();
        box1.add(newJLabel("课程号:"));
        box1.add(课程号);
        box2.add(newJLabel("课程名:"));
        box2.add(课程名);
        box3.add(newJLabel("先修课课程号:"));
        box3.add(先修课课程号);
        box4.add(newJLabel("学分:"));
        box4.add(学分);
        box6.add(录入);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);
        boxH.add(Box.createVerticalGlue());JPanel messPanel=newJPanel();
        messPanel.add(boxH);setLayout(newBorderLayout());add(messPanel,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent c){Object obj=c.getSource();if(obj==录入){if(课程号.getText().equals("")||课程名.getText().equals("")||先修课课程号.getText().equals("")||学分.getText().equals("")){JOptionPane.showMessageDialog(this,"学生信息请填满再录入!");}Statement stmt=null;ResultSet rs=null,rs1=null;String sql,sql1;
            sql1="select * from Course where Cno='"+课程号.getText()+"'";
            sql="insert into Course values('"+课程号.getText()+"','"+课程名.getText()+"','"+先修课课程号.getText()+"','"+学分.getText()+"')";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"该课号以存在,无法添加");}else{
                    stmt.executeUpdate(sql);JOptionPane.showMessageDialog(this,"添加成功");}
                rs1.close();

                stmt.close();}catch(SQLException e){System.out.print("SQL Exception occur.Message is:"+e.getMessage());}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

AddS

/*
AddS
*/packagesc;importjava.awt.*;importjavax.swing.*;importjava.sql.*;importjava.awt.event.*;publicclassAddSextendsJPanelimplementsActionListener{JTextField 学号,姓名,性别,年龄,所在系系名;JButton 录入;publicAddS(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        学号=newJTextField(12);
        姓名=newJTextField(12);
        性别=newJTextField(12);
        年龄=newJTextField(12);
        所在系系名=newJTextField(12);
        录入=newJButton("录入");
        录入.addActionListener(this);Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();
        box1.add(newJLabel("学号:"/*,JLabel.CENTER*/));
        box1.add(学号);
        box2.add(newJLabel("姓名:"/*,JLabel.CENTER*/));
        box2.add(姓名);
        box3.add(newJLabel("性别:"/*,JLabel.CENTER*/));
        box3.add(性别);
        box4.add(newJLabel("年龄:"/*,JLabel.CENTER*/));
        box4.add(年龄);
        box5.add(newJLabel("所在系系名:"/*,JLabel.CENTER*/));
        box5.add(所在系系名);
        box6.add(录入);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);
        boxH.add(Box.createVerticalGlue());JPanel messPanel=newJPanel();
        messPanel.add(boxH);setLayout(newBorderLayout());add(messPanel,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent c){Object obj=c.getSource();if(obj==录入){if(学号.getText().equals("")||姓名.getText().equals("")||性别.getText().equals("")||年龄.getText().equals("")||所在系系名.getText().equals("")){JOptionPane.showMessageDialog(this,"学生信息请填满再录入!");}Statement stmt=null;ResultSet rs1=null;String sql,sql1;
            sql1="select * from Student where Sno='"+学号.getText()+"'";
            sql="insert into Student values('"+学号.getText()+"','"+姓名.getText()+"','"+性别.getText()+"','"+年龄.getText()+"','"+所在系系名.getText()+"')";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"该学号已经存在,无法添加");}else{
                    stmt.executeUpdate(sql);JOptionPane.showMessageDialog(this,"添加成功");}
                rs1.close();
                stmt.close();}catch(SQLException e){System.out.print("SQL Exception occur.Message is:"+e.getMessage());}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

AddSC

/*
AddSC
*/packagesc;importjava.awt.*;importjavax.swing.*;importjava.sql.*;importjava.util.*;importjavax.swing.filechooser.*;importjava.io.*;importjava.awt.event.*;publicclassAddSCextendsJPanelimplementsActionListener{JTextField 课程号,学号,成绩;JButton 录入;publicAddSC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        课程号=newJTextField(12);
        学号=newJTextField(12);
        成绩=newJTextField(12);
        录入=newJButton("录入");
        录入.addActionListener(this);Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();
        box1.add(newJLabel("课号:"));
        box1.add(课程号);
        box2.add(newJLabel("学号:"));
        box2.add(学号);
        box3.add(newJLabel("成绩:"));
        box3.add(成绩);
        box4.add(录入);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(Box.createVerticalGlue());JPanel messPanel=newJPanel();
        messPanel.add(boxH);setLayout(newBorderLayout());add(messPanel,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent c){Object obj=c.getSource();if(obj==录入){if(课程号.getText().equals("")||学号.getText().equals("")){JOptionPane.showMessageDialog(this,"填写课号与学号才能录入!");}else{Statement stmt=null;ResultSet rs=null,rs1=null,rsC=null,rsS=null;String sql,sql1,sqlS,sqlC;
                sqlC="select * from Course where Cno='"+课程号.getText()+"'";
                sqlS="select * from Student where Sno='"+学号.getText()+"'";
                sql1="select * from SC where Cno='"+课程号.getText()+"' and Sno='"+学号.getText()+"'";
                sql="insert into SC values('"+学号.getText()+"','"+课程号.getText()+"','"+成绩.getText()+"')";try{Connection dbConn1=CONN();
                    stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    rsC=stmt.executeQuery(sqlC);if(rsC.next()){
                        rsS=stmt.executeQuery(sqlS);if(rsS.next()){
                            rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"该学生以选该课程号,无法添加");}else{
                                stmt.executeUpdate(sql);JOptionPane.showMessageDialog(this,"添加成功");}
                            rs1.close();}else{JOptionPane.showMessageDialog(this,"该学生不存在,无法添加");}
                        rsS.close();}else{JOptionPane.showMessageDialog(this,"该课程不存在,无法添加");}
                    rsC.close();
                    stmt.close();}catch(SQLException e){System.out.print("SQL Exception occur.Message is:"+e.getMessage());}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

DelC

/*
DelC
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassDelCextendsJPanelimplementsActionListener{String save=null;JTextField 课号1,课程号,课程名,先修课课程号,学分;JButton 删除,查找;publicDelC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        课号1=newJTextField(12);
        课程号=newJTextField(12);
        课程名=newJTextField(12);
        先修课课程号=newJTextField(12);
        学分=newJTextField(12);
        删除=newJButton("删除");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();Box box7=Box.createHorizontalBox();
        box1.add(newJLabel("课程号:",JLabel.CENTER));
        box1.add(课程号);
        box2.add(newJLabel("课程名:",JLabel.CENTER));
        box2.add(课程名);
        box3.add(newJLabel("先修课课程号:",JLabel.CENTER));
        box3.add(先修课课程号);
        box4.add(newJLabel("学分:",JLabel.CENTER));
        box4.add(学分);
        box6.add(删除);
        box7.add(newJLabel("课号:",JLabel.CENTER));
        box7.add(课号1);
        box7.add(查找);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);//boxH.add(box7);
        boxH.add(Box.createVerticalGlue());

        删除.addActionListener(this);
        查找.addActionListener(this);JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box7);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null;String sql=null,sql1=null,sqlSC=null;if(obj==查找){if(课号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写查询的课号!");else{
            sql1="select * from Course where Cno='"+课号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){课程号.setText(rs1.getString("Cno").trim());
                    课程名.setText(rs1.getString("Cname").trim());
                    先修课课程号.setText(rs1.getString("Cpno").trim());
                    学分.setText(rs1.getString("Ccredit").trim());
                    save=课号1.getText().trim();}else{JOptionPane.showMessageDialog(this,"没有这个课号的课程");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==删除){if(save==null)JOptionPane.showMessageDialog(this,"还没查找需要修改的课程");else{sql="delete from Course where Cno='"+save+"'";
                sqlSC="delete from SC where Cno='"+save+"'";try{Connection dbConn1=CONN();
                    stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    stmt.executeUpdate(sql);
                    stmt.executeUpdate(sqlSC);
                    save=null;JOptionPane.showMessageDialog(this,"删除完成");
                    课程号.setText("");
                    课程名.setText("");
                    先修课课程号.setText("");
                    学分.setText("");
                    stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}//    连接数据库方法publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

DelS

/*
DelS
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassDelSextendsJPanelimplementsActionListener{String save=null;JTextField 学号1,学号,姓名,性别,年龄,所在系系名;JButton 删除,查找;publicDelS(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        学号1=newJTextField(12);
        学号=newJTextField(12);
        姓名=newJTextField(12);
        性别=newJTextField(12);
        年龄=newJTextField(12);
        所在系系名=newJTextField(12);
        删除=newJButton("删除");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();Box box7=Box.createHorizontalBox();

        box1.add(newJLabel("学号:",JLabel.CENTER));
        box1.add(学号);
        box2.add(newJLabel("姓名:",JLabel.CENTER));
        box2.add(姓名);
        box3.add(newJLabel("性别:",JLabel.CENTER));
        box3.add(性别);
        box4.add(newJLabel("年龄:",JLabel.CENTER));
        box4.add(年龄);
        box5.add(newJLabel("所在系系名:",JLabel.CENTER));
        box5.add(所在系系名);
        box6.add(删除);
        box7.add(newJLabel("学号:",JLabel.CENTER));
        box7.add(学号1);
        box7.add(查找);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);

        boxH.add(Box.createVerticalGlue());

        删除.addActionListener(this);
        查找.addActionListener(this);JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box7);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null;String sql=null,sql1=null,sqlSC=null;if(obj==查找){if(学号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写查询的学号!");else{
            sql1="select * from Student where Sno='"+学号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){学号.setText(rs1.getString("Sno").trim());
                    姓名.setText(rs1.getString("Sname").trim());
                    性别.setText(rs1.getString("Ssex").trim());
                    年龄.setText(rs1.getString("Sage").trim());
                    所在系系名.setText(rs1.getString("Sdept").trim());
                    save=学号1.getText().trim();}else{JOptionPane.showMessageDialog(this,"没有这个学号的学生");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==删除){if(save==null)JOptionPane.showMessageDialog(this,"还没查找需要修改的学生");else{sql="delete from Student where Sno='"+save+"'";
                sqlSC="delete from SC where Sno='"+save+"'";try{Connection dbConn1=CONN();
                    stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    stmt.executeUpdate(sql);
                    stmt.executeUpdate(sqlSC);
                    save=null;JOptionPane.showMessageDialog(this,"删除完成");
                    学号.setText("");
                    姓名.setText("");
                    性别.setText("");
                    年龄.setText("");
                    所在系系名.setText("");

                    stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

DelSC

/*
DelSC
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassDelSCextendsJPanelimplementsActionListener{String saveC=null;String saveS=null;JTextField 课号1,学号1,学号,课程号,成绩;JButton 删除,查找;publicDelSC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        学号1=newJTextField(12);
        课号1=newJTextField(12);
        课程号=newJTextField(12);
        学号=newJTextField(12);
        成绩=newJTextField(12);
        删除=newJButton("删除");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();
        box1.add(newJLabel("课程号:",JLabel.CENTER));
        box1.add(课程号);
        box2.add(newJLabel("学号:",JLabel.CENTER));
        box2.add(学号);
        box3.add(newJLabel("成绩:",JLabel.CENTER));
        box3.add(成绩);
        box4.add(删除);
        box5.add(newJLabel("课号:",JLabel.CENTER));
        box5.add(课号1);
        box5.add(newJLabel("学号:",JLabel.CENTER));
        box5.add(学号1);
        box5.add(查找);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(Box.createVerticalGlue());

        删除.addActionListener(this);
        查找.addActionListener(this);JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box5);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null;String sql=null,sql1=null;if(obj==查找){if(课号1.getText().equals("")||学号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写完成查询的信息!");else{

            sql1="select * from SC where Cno='"+课号1.getText()+"' and Sno='"+学号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){课程号.setText(rs1.getString("Cno").trim());
                    学号.setText(rs1.getString("Sno").trim());
                    成绩.setText(rs1.getString("grade").trim());
                    saveC=课号1.getText().trim();
                    saveS=学号1.getText().trim();}else{JOptionPane.showMessageDialog(this,"没有这个课号的学生");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==删除){if(saveC==null||saveS==null)JOptionPane.showMessageDialog(this,"还没查找需要修改的学生/课程");else{sql="delete from SC where Cno='"+saveC+"' and Sno='"+saveS+"'";try{Connection dbConn1=CONN();
                    stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                    stmt.executeUpdate(sql);
                    saveC=null;
                    saveS=null;JOptionPane.showMessageDialog(this,"删除完成");
                    课程号.setText("");
                    学号.setText("");
                    成绩.setText("");
                    stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

SelC

/*
SelC
*/packagesc;importjava.sql.*;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjava.util.*;publicclassSelCextendsJFrame{Vector rowData, columnNames;Statement stmt=null;String sql=null;JTable jt =null;JScrollPane jsp =null;PreparedStatement ps=null;ResultSet rs=null;publicSelC(String sql1){
        columnNames =newVector();// 设置列名
        columnNames.add("课程号");
        columnNames.add("课程名");
        columnNames.add("先修课课程号");
        columnNames.add("学分");
        rowData=newVector();
        sql=sql1;try{Connection dbConn1=CONN();
            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            rs=stmt.executeQuery(sql);while(rs.next()){Vector hang =newVector();
                hang.add(rs.getString("Cno"));System.out.print(rs.getString("Cno"));
                hang.add(rs.getString("Cname"));System.out.print(rs.getString("Cname"));
                hang.add(rs.getString("Cpno"));System.out.print(rs.getString("Cpno"));
                hang.add(rs.getString("Ccredit"));System.out.print(rs.getString("Ccredit"));
                rowData.add(hang);}
            jt=newJTable(rowData,columnNames);
            jsp=newJScrollPane(jt);this.add(jsp);this.setSize(400,300);this.setVisible(true);}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

SelS

/*
SelS
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassSelSextendsJPanelimplementsActionListener{JTextField 学号,姓名,性别,年龄,所在系系名;JButton 查找;JTextField 课程号,课程名,先修课课程号,学分;JButton 查找1;JTextField 课号1,学号1,成绩;JButton 查找2;publicSelS(){
        学号=newJTextField(12);
        姓名=newJTextField(12);
        性别=newJTextField(12);
        年龄=newJTextField(12);
        所在系系名=newJTextField(12);
        课程号=newJTextField(12);
        课程名=newJTextField(12);
        先修课课程号=newJTextField(12);
        学分=newJTextField(12);
        课号1=newJTextField(12);
        学号1=newJTextField(12);
        成绩=newJTextField(12);
        查找=newJButton("查找学生信息");
        查找1=newJButton("查找课程信息");
        查找2=newJButton("查找选课信息");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();Box box7=Box.createHorizontalBox();
        box1.add(newJLabel("学号:",JLabel.CENTER));
        box1.add(学号);
        box1.add(newJLabel("姓名:",JLabel.CENTER));
        box1.add(姓名);
        box1.add(newJLabel("性别:",JLabel.CENTER));
        box1.add(性别);
        box1.add(newJLabel("年龄:",JLabel.CENTER));
        box1.add(年龄);
        box1.add(newJLabel("所在系系名:",JLabel.CENTER));
        box1.add(所在系系名);
        box2.add(查找);

        box4.add(newJLabel("课程号:",JLabel.CENTER));
        box4.add(课程号);
        box4.add(newJLabel("课程名:",JLabel.CENTER));
        box4.add(课程名);
        box4.add(newJLabel("先修课课程号:",JLabel.CENTER));
        box4.add(先修课课程号);
        box4.add(newJLabel("学分:",JLabel.CENTER));
        box4.add(学分);
        box6.add(查找1);

        box5.add(newJLabel("课程号:",JLabel.CENTER));
        box5.add(课号1);
        box5.add(newJLabel("学号:",JLabel.CENTER));
        box5.add(学号1);
        box5.add(newJLabel("成绩:",JLabel.CENTER));
        box5.add(成绩);
        box7.add(查找2);Box boxH1=Box.createVerticalBox();//竖放box
        boxH1.add(box1);
        boxH1.add(box2);
        boxH1.add(Box.createVerticalGlue());Box boxH2=Box.createVerticalBox();//竖放box
        boxH2.add(box4);
        boxH2.add(box6);
        boxH2.add(Box.createVerticalGlue());Box boxH3=Box.createVerticalBox();//竖放box
        boxH3.add(box5);
        boxH3.add(box7);
        boxH3.add(Box.createVerticalGlue());

        查找.addActionListener(this);
        查找1.addActionListener(this);
        查找2.addActionListener(this);JPanel messPanel=newJPanel();JPanel picPanel=newJPanel();JPanel threePanel=newJPanel();
        messPanel.add(boxH1);
        picPanel.add(boxH2);
        threePanel.add(boxH3);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);JSplitPane splitV1=newJSplitPane(JSplitPane.VERTICAL_SPLIT,splitV,threePanel);//分割add(splitV1,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent c){Object obj=c.getSource();Statement stmt=null;ResultSet rs=null;int row=0;int i=0;String sql=null;//Student K;SelC K1;SelS K2;if(obj==查找){if(学号.getText().equals("")&&姓名.getText().equals("")&&性别.getText().equals("")&&年龄.getText().equals("")&&所在系系名.getText().equals("")){
                sql="select * from Student ";System.out.print("00");//00}elseif(学号.getText().equals("")){if(姓名.getText().equals("")){if(性别.getText().equals("")){if(年龄.getText().equals("")){
                            sql="select * from Student where Sdept like'%"+所在系系名.getText()+"%'";System.out.print("10");}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}}else{if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Ssex like'%"+性别.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}}}else{if(性别.getText().equals("")){if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sname like'%"+姓名.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sage like '%"+年龄.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sage like '%"+年龄.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}}else{if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sname like '%"+姓名.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sname like '%"+姓名.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sname like '%"+姓名.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sname like '%"+姓名.getText()+"%'";}}}}}else{if(姓名.getText().equals("")){if(性别.getText().equals("")){if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sno like'%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sno like'%"+学号.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sno like '%"+姓名.getText()+"%'";}}}else{if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}}}else{if(性别.getText().equals("")){if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sage like '%"+年龄.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sname like'%"+姓名.getText()+"%'and Sage like '%"+年龄.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}}else{if(年龄.getText().equals("")){if(所在系系名.getText().equals("")){
                                sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sname like '%"+姓名.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Ssex like'%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sname like '%"+姓名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}else{if(所在系系名.getText().equals("")){
                                sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sname like '%"+姓名.getText()+"%'and Sno like '%"+学号.getText()+"%'";System.out.print("10");}else{sql="select * from Student where Sage like'%"+年龄.getText()+"%'and Ssex like '%"+性别.getText()+"%'and Sdept like '%"+所在系系名.getText()+"%'and Sname like '%"+姓名.getText()+"%'and Sno like '%"+学号.getText()+"%'";}}}}}//K=new Student(sql);}else{if(obj==查找1){if(课程号.getText().equals("")&&课程名.getText().equals("")&&先修课课程号.getText().equals("")&&学分.getText().equals("")){
                sql="select * from Course ";System.out.print("00");//00}elseif(课程号.getText().equals("")){if(课程名.getText().equals("")){if(先修课课程号.getText().equals("")){
                        sql="select * from Course where Ccredit like'%"+学分.getText()+"%'";System.out.print("10");}else{if(学分.getText().equals("")){sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'and Ccredit like '%"+学分.getText()+"%'";}}}else{if(先修课课程号.getText().equals("")&&学分.getText().equals("")){
                        sql="select * from Course where Cno like'%"+课程号.getText()+"%'";System.out.print("10");}else{if(先修课课程号.getText().equals("")){
                            sql="select * from Course where Ccredit like'%"+学分.getText()+"%'and Cno like '%"+课程号.getText()+"%'";System.out.print("10");}else{if(学分.getText().equals("")){sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'and Ccredit like '%"+学分.getText()+"%'";}}}}}else{if(课程名.getText().equals("")){if(先修课课程号.getText().equals("")){if(学分.getText().equals("")){
                            sql="select * from Course where Cno like'%"+课程号.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Ccredit like'%"+学分.getText()+"%'and Cno like '%"+课程号.getText()+"%'";System.out.print("10");}}else{if(学分.getText().equals("")){
                            sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Ccredit like'%"+学分.getText()+"%'and Cpno like '%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'";System.out.print("10");}}}else{if(先修课课程号.getText().equals("")){if(学分.getText().equals("")){
                            sql="select * from Course where Cno like'%"+课程号.getText()+"%'and Cname like '%"+课程名.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Ccredit like'%"+学分.getText()+"%'and Cno like '%"+课程号.getText()+"%'and Cname like '%"+课程名.getText()+"%'";System.out.print("10");}}else{if(学分.getText().equals("")){
                            sql="select * from Course where Cpno like'%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'and Cname like '%"+课程名.getText()+"%'";System.out.print("10");}else{sql="select * from Course where Ccredit like'%"+学分.getText()+"%'and Cpno like '%"+先修课课程号.getText()+"%'and Cno like '%"+课程号.getText()+"%'and Cname like '%"+课程名.getText()+"%'";System.out.print("10");}}}}

            K1=newSelC(sql);}else{if(obj==查找2){if(课号1.getText().equals("")&&学号1.getText().equals("")&&成绩.getText().equals("")){
                sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("000");//000}else{if(课号1.getText().equals("")){if(学号1.getText().equals("")){
                        sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where grade like'%"+成绩.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("001");}else{if(成绩.getText().equals("")){sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where SC.Sno like'%"+学号1.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("010");}else{sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where SC.Sno like'%"+学号1.getText()+"%'and grade like'%"+成绩.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("011");}}}else{if(学号1.getText().equals("")){if(成绩.getText().equals("")){sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where SC.Cno like'%"+课号1.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("100");}else{sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where SC.Cno like'%"+课号1.getText()+"%' and grade like'%"+成绩.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("101");}}else{if(成绩.getText().equals("")){sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where  SC.Cno like'%"+课号1.getText()+"%' and SC.Sno like'%"+学号1.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("110");}else{sql="select SC.Cno,Cname,SC.Sno,Sname,grade from SC,Course,Student where  SC.Cno like'%"+课号1.getText()+"%' and SC.Sno like'%"+学号1.getText()+"%' and grade like'%"+成绩.getText()+"%' and Course.Cno=SC.Cno and Student.Sno=SC.Sno";System.out.print("111");}}}}
            K2=newSelS();}}}}}

SelSC

/*
SelSC
*/packagesc;importjava.sql.*;importjavax.swing.*;//import connection.java;importjava.util.*;publicclassSelSCextendsJFrame{Vector rowData, columnNames;Statement stmt=null;String sql=null;JTable jt =null;JScrollPane jsp =null;PreparedStatement ps=null;ResultSet rs=null;publicSelSC(String sql1){
        columnNames =newVector();// 设置列名
        columnNames.add("课程号");

        columnNames.add("学号");

        columnNames.add("成绩");

        rowData=newVector();
        sql=sql1;try{Connection dbConn1=CONN();
            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
            rs=stmt.executeQuery(sql);while(rs.next()){Vector hang =newVector();
                hang.add(rs.getString("Sno"));System.out.print(rs.getString("Sno"));
                hang.add(rs.getString("Cno"));System.out.print(rs.getString("Cno"));

                hang.add(rs.getString("grade"));System.out.println(rs.getString("grade"));
                rowData.add(hang);}
            jt=newJTable(rowData,columnNames);
            jsp=newJScrollPane(jt);this.add(jsp);this.setSize(400,300);this.setVisible(true);}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

UpdateC

/*
UpdateC
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassUpdateCextendsJPanelimplementsActionListener{String save=null;JTextField 课号1,课程号,课程名,先修课课程号,学分;JButton 修改,查找;publicUpdateC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        课号1=newJTextField(12);
        课程号=newJTextField(12);
        课程名=newJTextField(12);
        先修课课程号=newJTextField(12);
        学分=newJTextField(12);
        修改=newJButton("修改");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();Box box7=Box.createHorizontalBox();
        box1.add(newJLabel("课程号:",JLabel.CENTER));
        box1.add(课程号);
        box2.add(newJLabel("课程名:",JLabel.CENTER));
        box2.add(课程名);
        box3.add(newJLabel("先修课课程号:",JLabel.CENTER));
        box3.add(先修课课程号);
        box4.add(newJLabel("学分:",JLabel.CENTER));
        box4.add(学分);
        box6.add(修改);
        box7.add(newJLabel("课号:",JLabel.CENTER));
        box7.add(课号1);
        box7.add(查找);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);

        修改.addActionListener(this);
        查找.addActionListener(this);

        boxH.add(Box.createVerticalGlue());JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box7);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null;String sql=null,sql1=null,sqlSC=null;if(obj==查找){if(课号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写查询的课号!");else{
            sql1="select * from Course where Cno='"+课号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){课程号.setText(rs1.getString("Cno").trim());
                    课程名.setText(rs1.getString("Cname").trim());
                    先修课课程号.setText(rs1.getString("Cpno").trim());
                    学分.setText(rs1.getString("Ccredit").trim());
                    save=课号1.getText();}else{JOptionPane.showMessageDialog(this,"没有这个课号的课程");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==修改){if(save==null){JOptionPane.showMessageDialog(this,"还没查找需要修改的课程");}else{if(课程号.getText().equals("")||课程名.getText().equals("")||先修课课程号.getText().equals("")||学分.getText().equals("")){JOptionPane.showMessageDialog(this,"课程信息填满才能修改!");}else{sql="update Course set Cno='"+课程号.getText()+"',Cname='"+课程名.getText()+"',Cpno='"+先修课课程号.getText()+"',Ccredit='"+学分.getText()+"' where Cno='"+save+"'";if(save.trim().equals(课程号.getText().trim())){try{Connection dbConn1=CONN();
                            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                            stmt.executeUpdate(sql);
                            save=null;JOptionPane.showMessageDialog(this,"修改完成");
                            课程号.setText("");
                            课程名.setText("");
                            stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}else{sql1="select * from Course where Cno='"+课程号.getText()+"'";try{Connection dbConn1=CONN();
                            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                            rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"已存在此课号课程");}else{sqlSC="update SC set Cno='"+课程号.getText()+"' where Cno='"+save+"'";
                                stmt.executeUpdate(sql);
                                stmt.executeUpdate(sqlSC);
                                save=null;JOptionPane.showMessageDialog(null,"修改完成");
                                课程号.setText("");
                                课程名.setText("");
                                先修课课程号.setText("");
                                学分.setText("");}
                            stmt.close();
                            rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

UpdateS

/*
UpdateS
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassUpdateSextendsJPanelimplementsActionListener{String save=null;JTextField 学号1,学号,姓名,性别,年龄,所在系系名;JButton 修改,查找;publicUpdateS(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        学号1=newJTextField(12);
        学号=newJTextField(12);
        姓名=newJTextField(12);
        性别=newJTextField(12);
        年龄=newJTextField(12);
        所在系系名=newJTextField(12);
        修改=newJButton("修改");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();Box box6=Box.createHorizontalBox();Box box7=Box.createHorizontalBox();
        box1.add(newJLabel("学号:",JLabel.CENTER));
        box1.add(学号);
        box2.add(newJLabel("姓名:",JLabel.CENTER));
        box2.add(姓名);
        box3.add(newJLabel("性别:",JLabel.CENTER));
        box3.add(性别);
        box4.add(newJLabel("年龄:",JLabel.CENTER));
        box4.add(年龄);
        box5.add(newJLabel("所在系系名:",JLabel.CENTER));
        box5.add(所在系系名);
        box6.add(修改);
        box7.add(newJLabel("学号:",JLabel.CENTER));
        box7.add(学号1);
        box7.add(查找);

        修改.addActionListener(this);
        查找.addActionListener(this);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(box5);
        boxH.add(box6);
        boxH.add(Box.createVerticalGlue());JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box7);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null;String sql=null,sql1=null,sqlSC;if(obj==查找){if(学号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写查询的学号!");else{

            sql1="select * from Student where Sno='"+学号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){学号.setText(rs1.getString("Sno").trim());
                    姓名.setText(rs1.getString("Sname").trim());
                    性别.setText(rs1.getString("Ssex").trim());
                    年龄.setText(rs1.getString("Sage").trim());
                    所在系系名.setText(rs1.getString("Sdept").trim());
                    save=学号1.getText();}else{JOptionPane.showMessageDialog(this,"没有这个学号的学生");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==修改){if(save==null){JOptionPane.showMessageDialog(this,"还没查找需要修改的学生");}else{if(学号.getText().equals("")||姓名.getText().equals("")||性别.getText().equals("")||年龄.getText().equals("")||所在系系名.getText().equals("")){JOptionPane.showMessageDialog(this,"学生信息填满才能修改!");}else{sql="update Student set Sno='"+学号.getText()+"',Sname='"+姓名.getText()+"',Ssex='"+性别.getText()+"',Sage='"+年龄.getText()+"',Sdept='"+所在系系名.getText()+"'where Sno='"+save+"'";if(save.trim().equals(学号.getText().trim())){try{Connection dbConn1=CONN();
                            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                            stmt.executeUpdate(sql);
                            save=null;JOptionPane.showMessageDialog(this,"修改完成");
                            学号.setText("");
                            姓名.setText("");
                            性别.setText("");
                            年龄.setText("");
                            所在系系名.setText("");
                            stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}else{sql1="select * from Student where Sno='"+学号.getText()+"'";try{Connection dbConn1=CONN();
                            stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                            rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"已存在此学号学生");}else{
                                sqlSC="update SC set Sno='"+学号.getText()+"' where Sno='"+save+"'";
                                stmt.executeUpdate(sql);
                                stmt.executeUpdate(sqlSC);
                                save=null;JOptionPane.showMessageDialog(null,"修改完成");
                                学号.setText("");
                                姓名.setText("");
                                性别.setText("");
                                年龄.setText("");
                                所在系系名.setText("");}
                            stmt.close();
                            rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

UpdateSC

/*
UpdateSC
*/packagesc;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;importjavax.swing.*;publicclassUpdateSCextendsJPanelimplementsActionListener{String saveC=null;String saveS=null;JTextField 课号1,学号1,学号,课程号,成绩;JButton 修改,查找;publicUpdateSC(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}

        学号1=newJTextField(12);
        课号1=newJTextField(12);
        课程号=newJTextField(12);
        学号=newJTextField(12);
        成绩=newJTextField(12);
        修改=newJButton("修改");
        查找=newJButton("查找");Box box1=Box.createHorizontalBox();//横放boxBox box2=Box.createHorizontalBox();Box box3=Box.createHorizontalBox();Box box4=Box.createHorizontalBox();Box box5=Box.createHorizontalBox();
        box1.add(newJLabel("课程号:",JLabel.CENTER));
        box1.add(课程号);
        box2.add(newJLabel("学号:",JLabel.CENTER));
        box2.add(学号);
        box3.add(newJLabel("成绩:",JLabel.CENTER));
        box3.add(成绩);
        box4.add(修改);
        box5.add(newJLabel("课号:",JLabel.CENTER));
        box5.add(课号1);
        box5.add(newJLabel("学号:",JLabel.CENTER));
        box5.add(学号1);
        box5.add(查找);Box boxH=Box.createVerticalBox();//竖放box
        boxH.add(box1);
        boxH.add(box2);
        boxH.add(box3);
        boxH.add(box4);
        boxH.add(Box.createVerticalGlue());

        修改.addActionListener(this);
        查找.addActionListener(this);JPanel picPanel=newJPanel();JPanel messPanel=newJPanel();
        messPanel.add(box5);
        picPanel.add(boxH);setLayout(newBorderLayout());JSplitPane splitV=newJSplitPane(JSplitPane.VERTICAL_SPLIT,messPanel,picPanel);//分割add(splitV,BorderLayout.CENTER);validate();}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();Statement stmt=null;ResultSet rs=null,rs1=null,rsC=null,rsS=null;String sql,sql1,sqlS,sqlC;if(obj==查找){if(课号1.getText().equals("")||学号1.getText().equals(""))JOptionPane.showMessageDialog(this,"请填写完成查询的信息!");else{
            sql1="select * from SC where Cno='"+课号1.getText()+"' and Sno='"+学号1.getText()+"'";try{Connection dbConn1=CONN();
                stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                rs1=stmt.executeQuery(sql1);if(rs1.next()){课程号.setText(rs1.getString("Cno").trim());
                    学号.setText(rs1.getString("Sno").trim());
                    成绩.setText(rs1.getString("grade").trim());
                    saveC=课号1.getText().trim();
                    saveS=学号1.getText().trim();}else{JOptionPane.showMessageDialog(this,"没有这个课号的学生");}
                stmt.close();
                rs1.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}else{if(obj==修改){if(saveC==null||saveS==null)JOptionPane.showMessageDialog(this,"还没查找需要修改的学生/课程");else{if(课程号.getText().equals("")||学号.getText().equals("")){JOptionPane.showMessageDialog(this,"课程信息填满才能修改!");}else{
                    sqlC="select * from Course where Cno='"+课程号.getText()+"'";
                    sqlS="select * from Student where Sno='"+学号.getText()+"'";
                    sql1="select * from SC where Cno='"+课程号.getText()+"' and Sno='"+学号.getText()+"'";
                    sql="update SC set Cno='"+课程号.getText()+"',Sno='"+学号.getText()+"',grade='"+成绩.getText()+"' where Cno='"+saveC+"' and Sno='"+saveS+"'";try{Connection dbConn1=CONN();
                        stmt=(Statement)dbConn1.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
                        rsC=stmt.executeQuery(sqlC);if(rsC.next()){
                            rsS=stmt.executeQuery(sqlS);if(rsS.next()){if(课程号.getText().trim().equals(saveC)&& 学号.getText().trim().equals(saveS)){
                                    stmt.executeUpdate(sql);JOptionPane.showMessageDialog(this,"添加成功");
                                    saveC=null;
                                    saveS=null;}else{rs1=stmt.executeQuery(sql1);if(rs1.next()){JOptionPane.showMessageDialog(this,"学生与课程号以存在,无法修改");}else{
                                        stmt.executeUpdate(sql);JOptionPane.showMessageDialog(this,"添加成功");
                                        saveC=null;
                                        saveS=null;}
                                    rs1.close();}}else{JOptionPane.showMessageDialog(this,"该学生不存在,无法修改");}
                            rsS.close();}else{JOptionPane.showMessageDialog(this,"该课程不存在,无法修改");}
                        rsC.close();
                        stmt.close();}catch(SQLException e1){System.out.print("SQL Exception occur.Message is:"+e1.getMessage());}}}}}}publicstaticConnectionCONN(){String driverName ="com.microsoft.sqlserver.jdbc.SQLServerDriver";//加载JDBC驱动String dbURL ="jdbc:sqlserver://主机名:1433; DatabaseName=数据库名";//连接服务器和数据库testString userName ="sa";//默认用户名String userPwd ="密码";//密码Connection dbConn=null;try{Class.forName(driverName);
            dbConn =DriverManager.getConnection(dbURL, userName, userPwd);System.out.println("Connection Successful!");//如果连接成功 控制台输出Connection Successful!}catch(Exception e){
            e.printStackTrace();}return dbConn;}}

Menu

packagesc;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassMenuextendsJFrameimplementsActionListener{AddS 增加学生界面;UpdateS 修改学生界面;DelS 删除学生界面;AddC 增加课程界面;DelC 删除课程界面;UpdateC 修改课程界面;AddSC 增加选课界面;DelSC 删除选课界面;UpdateSC 修改选课界面;SelS 学生查询界面;JPanel pCenter;CardLayout card=null;JLabel label=null;JMenuBar mb=newJMenuBar();//菜单栏JMenu m1=newJMenu("学生管理");JMenuItem add1=newJMenuItem("add   ");JMenuItem updata1=newJMenuItem("update   ");JMenuItem delete1=newJMenuItem("delete   ");JMenu m2=newJMenu("课程管理");JMenuItem add2=newJMenuItem("add   ");JMenuItem updata2=newJMenuItem("update   ");JMenuItem delete2=newJMenuItem("delete   ");JMenu m3=newJMenu("选课管理");JMenuItem add3=newJMenuItem("add   ");JMenuItem updata3=newJMenuItem("update   ");JMenuItem delete3=newJMenuItem("delete   ");JMenu m4=newJMenu("查询管理");JMenuItem 学生查询=newJMenuItem("查询信息   ");JMenuItem m5=newJMenuItem("系统退出");Font t=newFont("sanerif",Font.PLAIN,12);publicMenu(){this.setTitle("学生成绩管理系统");try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(Exception e){System.err.println("不能设置外观:   "+e);}//组合菜单addMenu1();addMenu2();addMenu3();addMenu4();addJMenuBar();setJMenuBar(mb);

        label=newJLabel("BJTU成绩管理系统",JLabel.CENTER);
        label.setFont(newFont("宋体",Font.BOLD,36));
        label.setHorizontalTextPosition(SwingConstants.CENTER);
        label.setForeground(Color.blue);//点击事件
        add1.addActionListener(this);
        updata1.addActionListener(this);
        delete1.addActionListener(this);
        m5.addActionListener(this);
        add2.addActionListener(this);
        delete2.addActionListener(this);
        updata2.addActionListener(this);
        add3.addActionListener(this);
        delete3.addActionListener(this);
        updata3.addActionListener(this);
        学生查询.addActionListener(this);

        card=newCardLayout();
        pCenter=newJPanel();
        pCenter.setLayout(card);

        增加学生界面=newAddS();
        修改学生界面=newUpdateS();
        删除学生界面=newDelS();
        增加课程界面=newAddC();
        删除课程界面=newDelC();
        修改课程界面=newUpdateC();
        增加选课界面=newAddSC();
        删除选课界面=newDelSC();
        修改选课界面=newUpdateSC();
        学生查询界面=newSelS();

        pCenter.add("欢迎界面",label);
        pCenter.add("增加学生界面",增加学生界面);
        pCenter.add("修改学生界面",修改学生界面);
        pCenter.add("删除学生界面",删除学生界面);
        pCenter.add("增加课程界面",增加课程界面);
        pCenter.add("删除课程界面",删除课程界面);
        pCenter.add("修改课程界面",修改课程界面);
        pCenter.add("增加选课界面",增加选课界面);
        pCenter.add("删除选课界面",删除选课界面);
        pCenter.add("修改选课界面",修改选课界面);
        pCenter.add("学生查询界面", 学生查询界面);add(pCenter,BorderLayout.CENTER);validate();setVisible(true);setBounds(400,150,1200,790);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);addWindowListener(newWindowAdapter(){//关闭程序时的操作publicvoidwindowClosing(WindowEvent e){System.exit(0);}});validate();}privatevoidaddJMenuBar(){
        mb.add(m1);mb.add(m2);mb.add(m3);mb.add(m4);mb.add(m5);}privatevoidaddMenu4(){
        m4.add(学生查询);
        m4.setFont(t);}privatevoidaddMenu3(){
        m3.add(add3);
        m3.add(updata3);
        m3.add(delete3);
        m3.setFont(t);}privatevoidaddMenu2(){//将菜单加入到菜单栏中
        m2.add(add2);
        m2.add(updata2);
        m2.add(delete2);
        m2.setFont(t);}privatevoidaddMenu1(){
        m1.add(add1);
        m1.add(updata1);
        m1.add(delete1);
        m1.setFont(t);//字体}publicvoidactionPerformed(ActionEvent e){Object obj=e.getSource();if(obj==m5){System.exit(0);}else{if(obj==add1){
            card.show(pCenter,"增加学生界面");}else{if(obj==updata1){
            card.show(pCenter,"修改学生界面");}else{if(obj==delete1){
            card.show(pCenter,"删除学生界面");}else{if(obj==add2){
            card.show(pCenter,"增加课程界面");}else{if(obj==delete2){
            card.show(pCenter,"删除课程界面");}else{if(obj==updata2){
            card.show(pCenter,"修改课程界面");}else{if(obj==add3){
            card.show(pCenter,"增加选课界面");}else{if(obj==delete3){
            card.show(pCenter,"删除选课界面");}else{if(obj==updata3){
            card.show(pCenter,"修改选课界面");}else{if(obj==学生查询){
            card.show(pCenter,"学生查询界面");}}}}}}}}}}}}publicstaticvoidmain(String[] args){newMenu();}}

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

idea链接数据库

File+settings+editor+plugins+database navigator+apply+ok
出现感叹号:
进connection+properties+serverTimezone+Asia/Shanghai+test connection

简单SQL语句

按老师要求还是进行一点语句补充吧(如果觉得费钱就把重复的代码保留一个表的,其他的做文字说明就可以了)
在这里插入图片描述
建表:

CREATETABLE student(
sno CHAR(10),
sname VARCHAR(20),
ssex CHAR(2),
sage INT,
sdept CHAR(15));

增:

insertinto 表名(属性1,属性2)value('内容1','内容2')

删:

deletefrom 表名 where 学号='****'

改:

update  表名  set  成绩=NULL

查:

select student.sno,sname,ssex,sage,sdept,cno
from 学生成绩管理.student,学生成绩管理.sc
where 学生成绩管理.student.sno=学生成绩管理.sc.sno

对成绩的查询:

select student.sname ,grade
from 学生成绩管理.student,学生成绩管理.sc
where 学生成绩管理.student.sno=学生成绩管理.sc.sno 

在这里插入图片描述

//不优秀的学生学号、课程号、成绩select sno,cno,grade
from 学生成绩管理.sc
where grade<80;//不优秀课程的学生学号selectdistinct sno
from 学生成绩管理.sc
where grade<80;//所有课程信息及选修该课程的学生学号及成绩select cname,sno,grade
from 学生成绩管理.sc,学生成绩管理.course
where 学生成绩管理.course.cno =学生成绩管理.sc.cno

/*选修5号课程成绩80分以上学生学号姓名及成绩
select student.sno,sname,grade
from 学生成绩管理.sc
where 学生成绩管理.student.sno=学生成绩管理.sc.sno
and sc.cno='5'
and sc.grade>80
*///每个学生及选修课程名及成绩select student.sno,sname,cname,sc.grade
from 学生成绩管理.student,学生成绩管理.sc,学生成绩管理.course
where student.sno=sc.sno
and sc.cno=course.cno

对成绩的统计:
1、使用MAX ()函数统计某个字段最大数据;
2、使用MIN ()函数统计某个字段最小数据;
3、使用COUNT ()函数统计查询结果的行数;
4、使用SUM ()函数统计数据之和;
5、使用AVG ()函数统计平均数。 MySQL MAX () 函数

答辩

好了好了就到这里,答辩讲解需求分析和E-R图为主,明天答辩祝我自己好运,过过过


本文转载自: https://blog.csdn.net/weixin_57780589/article/details/124687211
版权归原作者 佳美不ERROR 所有, 如有侵权,请联系我们删除。

“mysql数据库学生成绩管理系统”的评论:

还没有评论