精华内容
下载资源
问答
  • Java简单学生管理系统不需要手动输入,笔记记录//student`public class student(){private String id;//学号private String name;//姓名private int age;//年龄public String getId() {return id;}public void setId...

    Java简单学生管理系统

    不需要手动输入,笔记记录

    //student`

    public class student(){

    private String id;//学号

    private String name;//姓名

    private int age;//年龄

    public String getId() {

    return id;

    }

    public void setId(String id) {

    this.id = id;

    }

    public String getName() {

    return name;

    }

    public void setName(String name) {

    this.name = name;

    }

    public int getAge() {

    return age;

    }

    public void setAge(int age) {

    this.age = age;

    }

    @Override

    public String toString() {

    return "Student{" +

    "id='" + id + '\'' +

    ", name='" + name + '\'' +

    ", age=" + age +

    '}';

    }

    public Student(String id, String name, int age) {

    this.id = id;

    this.name = name;

    this.age = age;

    }

    }

    //studentManger

    public class StudentManager {

    Student[] stus=new Student[20];//声明数组

    static int count=0;//学生数量

    public void add(Student stu){

    stus[count] =stu;

    count++;

    }

    //查一条数据

    public void findByid(String id){

    for (int i = 0; i < stus.length; i++) {

    Student stu=this.stus[i];

    if (stu.getId().equals(id)){

    System.out.println(stu);

    }

    }

    }

    //查询所有

    public void findAll(){

    for (int i = 0; i < count; i++) {

    System.out.println(stus[i]);

    }

    }

    //修改

    public void udp(String id,Student student){

    for (int i = 0; i < stus.length; i++) {

    Student stu=this.stus[i];

    if (stu.getId().equals(id)){

    stus[i]=student;

    findAll();

    }

    }

    }

    //删除

    public void del(String id){

    for (int i = 0; i < count; i++) {

    if (stus[i].getId()==id){

    for (int j = i; j

    if (stus[j]!=null){

    stus[j]=stus[j+1];

    }

    }

    count--;

    }

    }

    }

    public static void main(String[] args) {

    //添加数据

    StudentManager sm=new StudentManager();

    Student s1=new Student("01","tom",20);

    sm.add(s1);

    Student s2=new Student("02","lili",19);

    sm.add(s2);

    //Student s3=new Student("02","lucy",19);修改数据

    //sm.udp("02",s3);

    // sm.del("02");删除数据

    //sm.findByid("02");查找一个数据

    sm.findAll();//查询所有

    }

    }

    添加数据的效果图

    需要实现那个功能就调用哪个方法。

    展开全文
  • Javaweb学生管理系统

    2019-01-24 21:43:22
    代码的功能预览图可以去我本人的博客查看,地址:https://blog.csdn.net/qq_36654606/article/details/86633857 有一篇专门的博客介绍。
  • 基于Java和MySQL(jdbc)设计的学生管理系统,GUI界面实现增加、修改、删除、查询功能。首先电脑要配置好ODBC数据源,下载有Mysql和eclipse,eclipse里面导入有jdbc包,MySQL创建有自己的数据库和表,再把代码里的...
  • 3. 增加学生信息界面:增加信息数据 4. 查找学生信息界面 (1) 根据学号查找:返回学生信息 (2) 查找全部: 返回学生信息 5. 修改学生信息界面:修改信息数据 6. 删除学生信息界面:删除信息数据 关注微信公众号:让...
  • Python+Mysql写的学生管理系统,sql语句也一并附上了,基础功能外还对各属性值进行校验是否符合规定,比较完善了,有问题欢迎发邮件找我探讨
  • Qt学生管理系统.zip

    2020-04-02 15:57:39
    本人的学习笔记,python的Qt开发,学生成绩管理系统源码。Qt学生管理系统.zip作为存档使用。后续可能会上传步骤参考。
  • java web简单学生信息管理系统 项目描述 利用Java以及jsp等技术实现学生信息管理,学生可以自己注册登记,教师进行学生管理,快捷方便合理利用资源。 运行环境 jdk7+tomcat8+mysql+IntelliJ IDEA 项目技术(必填...
  • Java实现简单的学生管理系统

    万次阅读 2019-04-15 20:07:11
    在java控制台上实现学生信息的管理 环境:ide + mysql 数据库: 学生的一张表 老师的一张表: 目录建成后是这样的: 实现的功能有: 教师登陆 1、学生信息添加 2、学生信息查看 3、学生信息删除 4、学生信息...

    在java控制台上实现学生信息的管理

    环境:ide + mysql
    数据库:
    创建数据库命令

    create database ***;
    use ***;
    然后分别创建两张表即可
    (当初学的比较呆,建了两个库,可以自己改成一个库)
    

    学生的一张表
    在这里插入图片描述

    create table student
    (
        id      int(10) auto_increment
            primary key,
        stuid   varchar(30)     null,
        stuname varchar(30)     null,
        pwd     varchar(30)     null,
        math    int default '0' null,
        eng     int default '0' null,
        java    int default '0' null,
        class   int default '0' null
    )
        charset = utf8;
    

    老师的一张表:
    在这里插入图片描述

    create table teacher
    (
        id        int(10) auto_increment
            primary key,
        teacherid varchar(30)     null,
        pwd       varchar(30)     null,
        class     int default '0' null
    )
        charset = utf8;
    
    

    目录建成后是这样的:
    在这里插入图片描述
    实现的功能有:

    • 教师登陆
      1、学生信息添加
      2、学生信息查看
      3、学生信息删除
      4、学生信息查询
      5、学生信息排名
      6、教师修改密码

    • 教师注册

    • 学生登陆
      1、信息查看
      2、信息修改

    • 退出

    denglu->studentdenglu

    package StudentServer.denglu;
    
    import StudentServer.mysql.JDBCUnity;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.*;
    
    
    public class studentdenglu {
        Map map = new HashMap();
        String pwd1 = null;
        String id1 = null;
        int ID ;
        public void read() {
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("studentdata");
                ps = con.prepareStatement("select stuid,pwd from student where id>=?");
                ps.setObject(1, 0);
    
                rs = ps.executeQuery();
    
                while (rs.next()) {
                    map.put(rs.getObject("stuid"),rs.getObject("pwd"));
                }
    
            } catch (Exception e) {
                e.printStackTrace();
            }
    
    
        }
    
        public int denglu() throws SQLException, ClassNotFoundException {
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            int f = 0;
    
            Scanner scanner = new Scanner(System.in);
            read();
            if (map.isEmpty()){
                System.out.println("\t\t\t\t目前还没有学生!");
            }else {
                System.out.print("\t\t\t\t请输入学号:");
                id1 = scanner.nextLine();
                Set set = map.keySet();
                Iterator it = set.iterator();
                while (it.hasNext()){
                    if (it.next().equals(id1)){
                        while (true) {
                            System.out.print("\t\t\t\t请输入密码:");
                            pwd1 = scanner.nextLine();
                            if (pwd1.equals(map.get(id1))) {
                                con = JDBCUnity.getconnection("studentdata");
                                ps = con.prepareStatement("select id from student where stuid=? and pwd=?");
                                ps.setString(1, id1);
                                ps.setString(2, pwd1);
                                rs = ps.executeQuery();
                                while (rs.next())
                                    ID = rs.getInt(1);
                                f = ID;
                                break;
                            }
                            System.out.println("\t\t\t\t密码错误!!请重新输入!!!");
                        }
                    }
                }
            }
            if (f == 0){
                System.out.println("\t\t\t\t\t\t无此账号!");
                try {
                    Thread.sleep(1500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
    
            return f;
        }
    }
    
    

    denglu->tecaherdenglu

    package StudentServer.denglu;
    
    import StudentServer.mysql.JDBCUnity;
    import StudentServer.server.TeacherDemo;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.*;
    
    public class teacherdenglu {
        List<TeacherDemo> list = new ArrayList<>();
    
        public void read() {
    
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("teacherdata");
                ps = con.prepareStatement("select teacherid,pwd,class from teacher where id>=0");
    
                rs = ps.executeQuery();
                while (rs.next()) {
                    TeacherDemo teacherDemo = new TeacherDemo(rs.getString("teacherid"),rs.getString("pwd")
                    ,rs.getInt("class"));
                    list.add(teacherDemo);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        public int denglu() throws InterruptedException {
            list.clear();
            read();
            int f = 0;
            String pwd1 = null;
            if (list.isEmpty()){
                System.out.println("\t\t\t\t目前还没有教师注册!");
            }else{
            Scanner scanner = new Scanner(System.in);
            System.out.print("\t\t\t\t请输入账号:");
            String id = scanner.nextLine();
                for (TeacherDemo t:list
                     ) {
                    if (t.getId().equals(id)){
                        while (true) {
                            System.out.print("\t\t\t\t请输入密码:");
                            pwd1 = scanner.nextLine();
                            if (pwd1.equals(t.getPwd())) {
                                f = t.getClassid();
                                break;
                            }else {
                                System.out.println("\t\t\t\t密码错误,请重新输入!");
                            }
                        }
                    }
                }
    
            if (f == 0) {
                System.out.println("\t\t\t\t无此账号!");
                Thread.sleep(1500);
            }
        }
        return f;
        }
    }
    
    

    denglu->zhucetecaher

    package StudentServer.denglu;
    
    import StudentServer.menu.Checkid;
    import StudentServer.mysql.JDBCUnity;
    
    import java.sql.*;
    import java.util.Scanner;
    
    public class zhuceteacher {
        public void zhuce() {
            System.out.println("\t\t\t\t注册教师账号");
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("teacherdata");
    
                ps = con.prepareStatement("insert into teacher (teacherid,pwd,class) values (?,?,?)");
                System.out.print("\t\t\t\t请输入账号:");
                String id;
                while (true) {
                    id = scanner.nextLine();
                    boolean f = new Checkid(id).checkteacher();
                    if (f) {
                        System.out.println("\t\t\t\t账号重复,请重新输入!");
                        System.out.print("\t\t\t\t请输入账号:");
                    }
                    else break;
                }
                ps.setObject(1, id);
                System.out.print("\t\t\t\t请输入密码:");
                String pwd = scanner.nextLine();
                ps.setObject(2, pwd);
                System.out.print("\t\t\t\t\t班级:");
                int classid = scanner.nextInt();
                ps.setObject(3, classid);
    
                ps.execute();
    
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    

    menu->Checkid

    package StudentServer.menu;
    
    import StudentServer.mysql.JDBCUnity;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;
    
    
    public class Checkid {
        private String id;
        public Checkid(String id){
            this.id = id;
        }
        List<String> checklist = new ArrayList<>();
        public boolean checkstudent(){
            checklist.clear();
            boolean f = false;
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("studentdata");
                ps = con.prepareStatement("select stuid from student where id>=?");
                ps.setObject(1, 0);
    
                rs = ps.executeQuery();
    
                while (rs.next()) {
                    checklist.add(rs.getString(1));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            for (String t:checklist
                 ) {
                if (t.equals(id)){
                    f = true;
                    break;
                }
            }
    
            return f;
        }
        public boolean checkteacher(){
            checklist.clear();
            boolean f = false;
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("teacherdata");
                ps = con.prepareStatement("select teacherid from teacher where id>=?");
                ps.setObject(1, 0);
    
                rs = ps.executeQuery();
    
                while (rs.next()) {
                    checklist.add(rs.getString(1));
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            for (String t:checklist
                    ) {
                if (t.equals(id)){
                    f = true;
                    break;
                }
            }
    
            return f;
        }
    
    }
    
    

    menu->Stumenu

    package StudentServer.menu;
    
    import StudentServer.mysql.JDBCUnity;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.Scanner;
    
    @SuppressWarnings("all")
    public class Stumenu {
        int ID;
        public Stumenu(Integer ID){
            this.ID = ID;
        }
        public void menu() {
    
            int choice;
            Scanner scanner = new Scanner(System.in);
            while (true) {
                System.out.println("\t\t\t\t----------------1.信息查看----------------");
                System.out.println("\t\t\t\t----------------2.信息修改----------------");
                System.out.println("\t\t\t\t----------------0.退出    ----------------");
                System.out.print("\t\t\t\t\t\t请输入你要进行的操作:");
                choice = scanner.nextInt();
                if (choice == 0) break;
                switch (choice) {
                    case 1:
                        see();
                        break;
                    case 2:
                        change();
                        break;
                }
            }
        }
    
    
        public void see(){
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
                try {
                    con = JDBCUnity.getconnection("studentdata");
                    ps = con.prepareStatement("select * from student where id=?");
                    ps.setInt(1,ID);
                    rs = ps.executeQuery();
                    System.out.println("*********************************************************************************************");
                    while (rs.next()) {
                        int sum = rs.getInt(7)+rs.getInt(5)+rs.getInt(6);
                        System.out.println("\t\t|学号:" + rs.getString(2) + "|" + "姓名:" + rs.getString(3) + "|" + "密码:" +
                                rs.getString(4) + "|" + "数学:" + rs.getInt(5) + "|" + "英语:" + rs.getInt(6) + "|" +
                                "Java:" + rs.getInt(7) + "|" + "Sum:" + sum+ "|"+ "班级:" + rs.getInt(8)+ "|");
                    }
                    System.out.println("*********************************************************************************************");
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
        }
    
        public void change() {
            int choice;
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
                try {
                    con = JDBCUnity.getconnection("studentdata");
    
                        System.out.println("\t\t\t\t----------------1.修改姓名----------------");
                        System.out.println("\t\t\t\t----------------2.修改学号----------------");
                        System.out.println("\t\t\t\t----------------3.修改密码----------------");
                        System.out.println("\t\t\t\t----------------0.退出    ----------------");
                        System.out.println("\t\t\t\t\t\t请输入你要进行的操作:");
                        choice = scanner.nextInt();
                        scanner.nextLine();
                        switch (choice) {
                            case 1:
                                System.out.print("\t\t\t\t姓名改为:");
                                String name = scanner.nextLine();
                                ps = con.prepareStatement("update student set stuname=? where id=ID;");
                                ps.setString(1,name);
                                ps.execute();
                                break;
                            case 2:
                                System.out.print("\t\t\t\t学号改为:");
                                String id = scanner.nextLine();
                                ps = con.prepareStatement("update student set stuid=? where id=ID;");
                                ps.setString(1,id);
                                ps.execute();
                                break;
                            case 3:
                                System.out.print("\t\t\t\t密码改为:");
                                String pwd = scanner.nextLine();
                                ps = con.prepareStatement("update student set pwd=? where id=ID");
                                ps.setString(1,pwd);
                                ps.execute();
                                break;
                        }
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
        }
    }
    
    

    menu->Teachermenu

    package StudentServer.menu;
    
    import StudentServer.mysql.JDBCUnity;
    import StudentServer.server.StudentDemo;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.*;
    
    @SuppressWarnings("all")
    public class Teachermenu {
         private int classid;
         List< StudentDemo> list = new ArrayList<>();
         public Teachermenu(int classid){
             this.classid = classid;
         }
    
    
        public void menu() {
            int choice;
            Scanner scanner = new Scanner(System.in);
            while (true) {
                read();
                System.out.println("\t\t\t\t----------------1.信息添加----------------");
                System.out.println("\t\t\t\t----------------2.信息查看----------------");
                System.out.println("\t\t\t\t----------------3.信息修改----------------");
                System.out.println("\t\t\t\t----------------4.信息删除----------------");
                System.out.println("\t\t\t\t----------------5.信息查询----------------");
                System.out.println("\t\t\t\t----------------6.成绩排名----------------");
                System.out.println("\t\t\t\t--------------7.修改教师密码--------------");
                System.out.println("\t\t\t\t----------------0.退出    ----------------");
                System.out.print("\t\t\t\t\t\t请输入你要进行的操作:");
                choice = scanner.nextInt();
                if (choice == 0) break;
                switch (choice) {
                    case 1:
                        add();
                        break;//添加学生信息
                    case 2:
                        show();
                        break;
                    case 3:
                        change();
                        break;//修改学生信息
                    case 4:
                        delete();
                        break;//删除学生信息
                    case 5:
                        find();
                        break;//查询学生信息
                    case 6:
                        sort();
                        break;
                    case 7:
                        changeteacher();
                        break;
                }
            }
        }
        public void changeteacher(){
            int choice;
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            try {
                con = JDBCUnity.getconnection("teacherdata");
    
                System.out.print("\t\t\t\t教师账号:");
                String tid = scanner.nextLine();
                if (tid.equals("")){
                    System.out.println("\t\t\t\t账号不能为空!");
                    tid = scanner.nextLine();
                }
                System.out.print("\t\t\t\t密码改为:");
                String pwd = scanner.nextLine();
                if (pwd.equals("")){
                    System.out.println("\t\t\t\t密码不能为空!");
                    pwd = scanner.nextLine();
                }
                ps = con.prepareStatement("update teacher set pwd=? where teacherid=?;");
                ps.setString(1,pwd);
                ps.setString(2,tid);
                ps.execute();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("修改成功!");
            try {
                Thread.currentThread().sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    
        public void find(){
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            System.out.print("\t\t\t\t请输入要查询的学生学号:");
            String id = scanner.nextLine();
    
            try {
                con = JDBCUnity.getconnection("studentdata");
                ps = con.prepareStatement("select * from student where stuid=?");
                ps.setString(1,id);
                rs = ps.executeQuery();
                System.out.println("*********************************************************************************************");
                while (rs.next()) {
                    int sum = rs.getInt(7)+rs.getInt(5)+rs.getInt(6);
                    System.out.println("\t\t\t\t|学号:" + rs.getString(2) + "|" + "姓名:" + rs.getString(3) + "|" + "密码:" +
                            rs.getString(4) + "|" + "数学:" + rs.getInt(5) + "|" + "英语:" + rs.getInt(6) + "|" +
                            "Java:" + rs.getInt(7) + "|" + "Sum:" + sum+ "|"+"班级:" + rs.getInt(8) + "|");
                }
                System.out.println("*********************************************************************************************");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void change(){
            int choice;
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            boolean f = false;
            System.out.print("\t\t\t\t请输入学号:");
            String id = scanner.nextLine();
            for (StudentDemo t:list
                 ) {
                if (t.getId().equals(id)){
                    f = true;
                    break;
                }
            }
            if (f == false){
                System.out.println("\t\t\t\t此老师名下无此学生!或者此学生没有注册!");
                return;
            }
            try {
                con = JDBCUnity.getconnection("studentdata");
    
                System.out.println("\t\t\t\t----------------1.修改姓名----------------");
                System.out.println("\t\t\t\t----------------2.修改学号----------------");
                System.out.println("\t\t\t\t----------------3.修改密码----------------");
                System.out.println("\t\t\t\t----------------4.修改数学----------------");
                System.out.println("\t\t\t\t----------------5.修改英语----------------");
                System.out.println("\t\t\t\t----------------6.修改Java----------------");
                System.out.println("\t\t\t\t----------------7.修改班级----------------");
                System.out.println("\t\t\t\t----------------0.退出    ----------------");
                System.out.print("\t\t\t\t\t\t请输入你要进行的操作:");
                choice = scanner.nextInt();
                scanner.nextLine();
                switch (choice) {
                    case 1:
                        System.out.print("\t\t\t\t姓名改为:");
                        String name = scanner.nextLine();
                        ps = con.prepareStatement("update student set stuname=? where stuid=? and class=?;");
                        ps.setString(1,name);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 2:
                        System.out.print("\t\t\t\t学号改为:");
                        String id1 = scanner.nextLine();
                        ps = con.prepareStatement("update student set stuid=? where stuid=? and class=?;");
                        ps.setString(1,id1);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 3:
                        System.out.print("\t\t\t\t密码改为:");
                        String pwd = scanner.nextLine();
                        ps = con.prepareStatement("update student set pwd=? where stuid=? and class=?");
                        ps.setString(1,pwd);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 4:
                        System.out.print("\t\t\t\t数学改为:");
                        String math1 = scanner.nextLine();
                        ps = con.prepareStatement("update student set math=? where stuid=? and class=?;");
                        ps.setString(1,math1);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 5:
                        System.out.print("\t\t\t\t英语改为:");
                        String eng1 = scanner.nextLine();
                        ps = con.prepareStatement("update student set eng=? where stuid=? and class=?;");
                        ps.setString(1,eng1);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 6:
                        System.out.print("\t\t\t\tJava改为:");
                        String java1 = scanner.nextLine();
                        ps = con.prepareStatement("update student set java=? where stuid=? and class=?;");
                        ps.setString(1,java1);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                    case 7:
                        System.out.print("\t\t\t\t班级改为:");
                        int classid1 = scanner.nextInt();
                        ps = con.prepareStatement("update student set class=? where stuid=? and class=?;");
                        ps.setInt(1,classid1);
                        ps.setString(2,id);
                        ps.setInt(3,classid);
                        ps.execute();
                        break;
                }
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    
        public void sort(){
    
            int choice;
            Scanner scanner = new Scanner(System.in);
            while (true) {
                read();
                System.out.println("\t\t\t\t----------------1.数学排名----------------");
                System.out.println("\t\t\t\t----------------2.英语排名----------------");
                System.out.println("\t\t\t\t----------------3.Java排名----------------");
                System.out.println("\t\t\t\t----------------4.总分排名----------------");
                System.out.println("\t\t\t\t----------------0.退出    ----------------");
                System.out.print("\t\t\t\t\t\t请输入你要进行的操作:");
                choice = scanner.nextInt();
                if (choice == 0) break;
                switch (choice) {
                    case 1:
                        Collections.sort(list, new Comparator<StudentDemo>() {
                            @Override
                            public int compare(StudentDemo o1, StudentDemo o2) {
                                return -1 * ((Integer)(o1.getMath())).compareTo((Integer)o2.getMath());
                            }
                        });
                        break;
                    case 2:
                        Collections.sort(list, new Comparator<StudentDemo>() {
                            @Override
                            public int compare(StudentDemo o1, StudentDemo o2) {
                                return -1 * ((Integer)(o1.getEnglish())).compareTo((Integer)o2.getEnglish());
                            }
                        });
                        break;
                    case 3:
                        Collections.sort(list, new Comparator<StudentDemo>() {
                            @Override
                            public int compare(StudentDemo o1, StudentDemo o2) {
                                return -1 * ((Integer)(o1.getJava())).compareTo((Integer)o2.getJava());
                            }
                        });
                        break;
                    case 4:
                        Collections.sort(list, new Comparator<StudentDemo>() {
                            @Override
                            public int compare(StudentDemo o1, StudentDemo o2) {
                                return -1 * ((Integer)(o1.getSum())).compareTo((Integer)o2.getSum());
                            }
                        });
                        break;
                }
                show();
            }
    
    
        }
    
        public void show(){
            System.out.println("*********************************************************************************************");
            for ( StudentDemo t:list
                 ) {
                System.out.println("\t\t|学号:"+t.getId()+"|"+"姓名:"+t.getName()+"|"+"密码:"+
                        t.getPwd()+"|"+"数学:"+t.getMath()+"|"+"英语:"+t.getEnglish()+"|"+"Java:"+t.getJava()+
                        "|"+"Sum:"+t.getSum()+"|"+"Class:"+t.getClassid()+"|");
            }
            System.out.println("*********************************************************************************************");
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    
    
        public void add() {
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            int choice;
            while (true) {
                try {
                    con = JDBCUnity.getconnection("studentdata");
                    ps = con.prepareStatement("insert into student (stuid,stuname,pwd,math,eng,java,class) values (?,?,?,?,?,?,?)");
                    System.out.print("\t\t\t\t请输入学生id:");
                    String id;
                    while (true) {
                        id = scanner.nextLine();
                        if (id.equals("")){
                            System.out.println("学号不能为空!");
                            return;
                        }
                        boolean f = new Checkid(id).checkstudent();
                        if (f) {
                            System.out.println("\t\t\t\t学号重复,请重新输入!");
                            System.out.print("\t\t\t\t请输入学生id:");
                        }
                        else break;
                    }
                    ps.setObject(1, id);
                    System.out.print("\t\t\t\t请输入学生name:");
                    String name = scanner.nextLine();
                    if (name.equals("")){
                        System.out.println("\t\t\t\t姓名不能为空!");
                        return;
                    }
                    ps.setObject(2, name);
                    System.out.print("\t\t\t\t请输入学生密码:");
                    String pwd = scanner.nextLine();
                    if (pwd.equals("")){
                        System.out.println("\t\t\t\t密码不能为空!");
                        return;
                    }
                    ps.setObject(3, pwd);
                    System.out.print("\t\t\t\t数学:");int math = scanner.nextInt();
                    System.out.print("\t\t\t\t英语:");int eng = scanner.nextInt();
                    System.out.print("\t\t\t\tJava:");int java = scanner.nextInt();
                    ps.setInt(4,math);
                    ps.setInt(5,eng);
                    ps.setInt(6,java);
                    int classid1 = classid;
                    ps.setInt(7,classid1);
    
                    ps.execute();
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
                System.out.println("\t\t\t\t添加学生,按0退出,按1继续");
                choice = scanner.nextInt();
                if (choice == 0) break;
            }
        }
    
        public void delete() {
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
                try {
                    con = JDBCUnity.getconnection("studentdata");
                    System.out.println("\t\t\t\t按名称删除-->'1'    按学号删除-->'2'");
                    int choice = scanner.nextInt();
                    if (choice == 1) {
                        ps = con.prepareStatement("delete from student where stuname=? and class=?");
                        System.out.println("\t\t\t\t请输入学生name");
                        scanner.nextLine();
                        String name = scanner.nextLine();
                        if (name.equals("")){
                            System.out.println("\t\t\t\t姓名不能为空!");
                            return;
                        }
                        ps.setObject(1, name);
                        ps.setObject(2, classid);
                    }else {
                        ps = con.prepareStatement("delete from student where stuid=? and class=?");
                        System.out.println("\t\t\t\t请输入学生id");
                        scanner.nextLine();
                        String id = scanner.nextLine();
                        if (id.equals("")){
                            System.out.println("\t\t\t\t学号不能为空!");
                            return;
                        }
                        ps.setObject(1, id);
                        ps.setObject(2, classid);
                    }
    
                    ps.execute();
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
    
        }
    
        public void read() {
            list.clear();
            Scanner scanner = new Scanner(System.in);
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
    
            try {
                con = JDBCUnity.getconnection("studentdata");
                ps = con.prepareStatement("select stuid,stuname,pwd,math,eng,java,class from student where id>=? and class=?");
                ps.setObject(1, 0);
                ps.setInt(2,classid);
                rs = ps.executeQuery();
    
                while (rs.next()) {
                    int sum = rs.getInt(4)+rs.getInt(5)+rs.getInt(6);
                    StudentDemo stu =new StudentDemo(rs.getString(1),rs.getString(2),
                            rs.getString(3),rs.getInt(4),
                            rs.getInt(5),rs.getInt(6),sum,rs.getInt(7));
    
                    list.add(stu);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
    
        }
    
    }
    
    

    mysql->JDBCUtil

    package StudentServer.mysql;
    
    import java.sql.*;
    
    public class JDBCUnity {
        public static Connection getconnection(String type) throws SQLException, ClassNotFoundException {
            Class.forName("com.mysql.cj.jdbc.Driver");
            //建立连接
           return DriverManager.getConnection("jdbc:mysql://localhost:3306/"+type+"?useSSL=false&serverTimezone=UTC&characterEncoding=utf-8","root","qqq1234");
        }
        public static void close(PreparedStatement ps, ResultSet rs,Connection con){
            try {
                ps.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        public static void close( ResultSet rs,Connection con){
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        public static void close(Connection con){
            try {
                con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    
    }
    
    

    server->mainserver

    package StudentServer.server;
    
    import StudentServer.denglu.studentdenglu;
    import StudentServer.denglu.teacherdenglu;
    import StudentServer.denglu.zhuceteacher;
    import StudentServer.menu.Teachermenu;
    import StudentServer.menu.Stumenu;
    
    import java.util.Scanner;
    
    @SuppressWarnings("all")
    public class mainserver {
        public static void main(String[] args) throws Exception {
            int choice;
            Scanner scanner = new Scanner(System.in);
            while (true) {
                System.out.println("\t\t\t\t----------------1.教师登陆----------------");
                System.out.println("\t\t\t\t----------------2.教师注册----------------");
                System.out.println("\t\t\t\t----------------3.学生登陆----------------");
                System.out.println("\t\t\t\t----------------0.退出    ----------------");
                System.out.print("\t\t\t\t\t\t请输入你要进行的操作:");
                choice = scanner.nextInt();
                if (choice == 0) break;
                switch (choice) {
                    case 1:
                        dengluteacher();
                        break;
                    case 2:
                        new zhuceteacher().zhuce();
                        break;
                    case 3:
                        denglustudent();
                        break;
                }
            }
    
    
        }
        public static void dengluteacher() throws InterruptedException {
            int t = new teacherdenglu().denglu();
            if (t != 0) {
                Teachermenu teachermenu = new Teachermenu(t);
                teachermenu.menu();
            }
        }
    
        public static void denglustudent() throws Exception {
            int t = new studentdenglu().denglu();
            if (t != 0) {
                Stumenu stumenu = new Stumenu(t);
                stumenu.menu();
            }
        }
    }
    

    server->StudentDemo

    package StudentServer.server;
    
    public class StudentDemo {
        private String  id;
        private String name;
        private String pwd;
        private int Math = 0;
        private int Java = 0;
        private int English = 0;
        private int Sum;
        private int Classid;
    
        public StudentDemo(String id, String name, String pwd, int math, int china, int english, int sum,int Classid) {
            this.id = id;
            this.name = name;
            this.pwd = pwd;
            Math = math;
            Java = china;
            English = english;
            Sum = sum;
            this.Classid = Classid;
        }
    
        public int getClassid() {
            return Classid;
        }
    
        public void setClass(int aClass) {
            Classid = aClass;
        }
    
        public String getId() {
            return id;
        }
    
        public void setId(String id) {
            this.id = id;
        }
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public String getPwd() {
            return pwd;
        }
    
        public void setPwd(String pwd) {
            this.pwd = pwd;
        }
    
        public int getMath() {
            return Math;
        }
    
        public void setMath(int math) {
            Math = math;
        }
    
        public int getJava() {
            return Java;
        }
    
        public void setJava(int china) {
            Java = china;
        }
    
        public int getEnglish() {
            return English;
        }
    
        public void setEnglish(int english) {
            English = english;
        }
    
        public int getSum() {
            return English+Math+Java;
        }
    
        public void setSum(int sum) {
            Sum = sum;
        }
    
        public StudentDemo(int math, int china, int english) {
            Math = math;
            Java = china;
            English = english;
        }
    
    
    }
    
    

    server->TeacherDemo

    package StudentServer.server;
    
    public class TeacherDemo {
        private String  id;
        private String pwd;
        private int classid;
    
        public TeacherDemo(String id, String pwd, int classid) {
            this.id = id;
            this.pwd = pwd;
            this.classid = classid;
        }
    
        public String getId() {
            return id;
        }
    
        public void setId(String id) {
            this.id = id;
        }
    
        public String getPwd() {
            return pwd;
        }
    
        public void setPwd(String pwd) {
            this.pwd = pwd;
        }
    
        public int getClassid() {
            return classid;
        }
    
        public void setClassid(int classid) {
            this.classid = classid;
        }
    }
    
    
    展开全文
  • 学生信息管理系统

    2019-04-27 16:43:34
    学生信息管理系统 在使用本系统之前,需要做一些运行环境的搭建,具体步骤见该目录下的 --系统部署流程--。 系统部署完成以后,运行wamp,待服务全部启动之后,打开浏览器,输入:...
  • 学生信息管理系统课程设计,包含学生信息管理、学生成绩管理、院系管理、及所在专业信息管理。 有两种角色:学生和管理员。 UML建模:包含了类图、序列图、协作图、活动图、状态图。
  • 基于Java+Mysql的学生信息系统,使用web网页交互方式。 功能:学生信息管理、包括学生信息的新增、编辑、...且各个角色权限不一样,管理员有所有权限、教师只有班级管理和学生管理权限、学生只能查看和修改自己信息。
  • 系统使用Visual Studio2017作为IDE,使用C++进行编写,其中排序功能使用了冒泡排序。包括源代码、文档报告、测试数据以及功能介绍文档。课程设计结束,给大家作为参考。
  • HTML+JS+CSS实现学生信息管理系统效果页面增删改查翻页代码难点难点1难点2难点3难点4结语 效果 话不多说,直接看效果,本次代码较为复杂,希望大家可以耐心阅读,不懂的可以评论或者邮箱联系我(1079349989@qq.com)...
  • Vue+Bootstrap实现简易学生管理系统

    千次阅读 2021-02-06 12:04:29
    利用vue和bootstrap做了一个比较简易的学生管理系统!!! 废话不多说先来看看效果图 附上源代码: <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8"> <meta ...

    利用vue和bootstrap做了一个比较简易的学生管理系统!!!
    废话不多说先来看看效果图
    在这里插入图片描述
    在这里插入图片描述
    附上源代码:

    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>学生管理系统</title>
        <link href="../public/css/bootstrap.min.css" rel="stylesheet">
        <link href="../public/css/style.css" rel="stylesheet">
        <style>
            .row>div{border: 1px solid #000;}
            .modal{display: block;opacity:1;top: 100px; overflow:visible;}
        </style>
    </head>
    <body>
        <div id="app">
    
       
        <div class="container">
            <table class="table table-striped">
                <caption>学生管理系统v1.0-展示学生</caption>
                <tr>
                    <th>姓名</th>
                    <th>年龄</th>
                    <th>性别</th>
                    <th>操作</th>
                </tr>
                <tr v-for="item,key in stuInfoArr">
                    <td>{{item.name}}</td>
                    <td>{{item.age}}</td>
                    <td>{{item.gender}}</td>
                    <td><button @click="showDialog(item.name,key)" class="btn btn-danger btn-xs" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">删除</button></td>
                </tr>          
            </table>
        
            <hr>
            <hr>
            <hr>
            <form action="">
              <table class="table table-striped">
                  <caption>添加学生信息</caption>
                  <tr>
                      <td>项目</td>
                      <td>信息</td>
                  </tr>
                  <tr>
                      <td>姓名</td>
                      <td>
                          <input v-model="stuName" type="text" class="form-control" id="stuname" placeholder="姓名" name="stuname">
                      </td>  
                  </tr>
                  <tr>
                      <td>年龄</td>
                      <td>
                          <input v-model="stuAge" type="text" class="form-control" id="stuage" placeholder="年龄" name="stuage">
                      </td>  
                  </tr>
                  <tr>
                      <td>性别</td>
                      <td>
                          <label class="gen-span"><input v-model="stuGender" type="radio" class="radio-info" name="gender" checked value=""></label>
                          <label class="gen-span"><input v-model="stuGender" type="radio" class="radio-info" name="gender" value=""></label>
                          <label class="gen-span"><input v-model="stuGender" type="radio" class="radio-info" name="gender" value="保密"> 保密</label>
                      </td>
                  </tr>
              </table>
              <div style="text-align: center;"><input type="button" class="btn btn-info btn-sm add-btn" value="确定增加" @click="add"/></div>
              </form>
        </div>
        <!-- 删除按钮确认框 -->
        <div v-show="isDialogShow" class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
            <div class="modal-dialog" role="document">
              <div class="modal-content">
                <div class="modal-header">
                  <button @click="isDialogShow=false" type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                  <h4 class="modal-title" id="exampleModalLabel">确认框</h4>
                </div>
                <div class="modal-body">
                  <form>
                     <div class="form-group">
                      <label for="message-text" class="control-label">确定要删除<strong class="control-label-name" style="color:blue">{{delStuName}}</strong>吗?</label>
                    </div>
                  </form>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal" @click="isDialogShow=false">返回</button>
                  <a href="###" class="delete-a"><button type="button" class="btn btn-primary" @click="delStuInfo()">确认</button></a>
                </div>
              </div>
            </div>
          </div>
        </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>  
    		   new Vue({
    			   el: '#app',
    			   data: {
    				   stuInfoArr: [
    					{ name: '小明', age:12, gender:"男" },
    					{ name: '小红', age:10, gender:"女" },
    					{ name: '小刚', age:16, gender:"保密" }
                      ],
    				  isDialogShow: false,
    				  stuName: "",
    				  stuAge:"",
    				  stuGender:"男"	,
    				  delStuName:'xx',
    				  index: ""
    															  
    			   },
    			   methods:{
    				   add() {
    					   // 业务逻辑
    					   // 只要有一个为空就终止执行
    					   if(!this.stuName || !this.stuAge) {
    						   alert("姓名和年龄不能为空")
    						   return 
    					   }
    					   this.stuInfoArr.push({ name:this.stuName , age:this.stuAge, gender:this.stuGender })
    				   },
    				   // 点击删除按钮触发的函数
    				   showDialog(name,key) {
    					   this.isDialogShow = true,
    					   this.delStuName = name,
    					   this.index = key
    				   },
    				   delStuInfo() {
    					   // 真正实现删除功能
    					   this.stuInfoArr.splice(this.index, 1),
    					   this.isDialogShow = false
    				   }
    			   },			   			   			   		   
    		   })
    </script>
    </body>
    </html>
    
    展开全文
  • Java学生管理系统和数据库idea

    千次阅读 2020-03-12 13:01:15
    System.out.println("这是一个学生信息管理系统,最大容量为100,欢迎您对本系统的使用"); while (true) { System.out.println(); System.out.println("********1.信息添加********"); System.out....

    效果如图
    在这里插入图片描述
    需要文件代码6个
    在这里插入图片描述

    package StudentDemo;
    
    import java.util.Scanner;
    
    public class MainTest {
    
    	/**
    	 * main方法是程序的入口
    	 *
    	 * @param args
    	 */
    	public static void main(String args[]) {
    
    		int choice;
    
    		System.out.println("这是一个学生信息管理系统,最大容量为100,欢迎您对本系统的使用");
    		while (true) {
    			System.out.println();
    			System.out.println("********1.信息添加********");
    			System.out.println("********2.信息查看********");
    			System.out.println("********3.信息修改********");
    			System.out.println("********4.信息删除********");
    			System.out.println("********5.信息按成绩从低到高排序********");
    			System.out.println("********6.信息查询********");
    			System.out.println("********7.退出********");
    			System.out.println("===请输入你要进行的操作====");
    			@SuppressWarnings("resource")
    			Scanner scanner = new Scanner(System.in);
    			choice = scanner.nextInt();
    			if (choice == 7)
    				break;
    			switch (choice) {
    				case 1:
    					Tools_DB.add();
    					break;// 添加学生信息
    				case 2:
    					Tools_DB.show();
    					break;// 查询学生信息
    				case 3:
    					Tools_DB.change();
    					break;// 修改学生信息
    				case 4:
    					Tools_DB.delete();
    					break;// 删除学生信息
    				case 5:
    					Tools_DB.paixu();
    					break;// 对学生信息排序
    				case 6:
    					Tools_DB.query();
    					break;// 查询学生信息
    				case 7:
    					System.out.println("您要操作的是:7.退出");
    					System.exit(0);
    					break;// 表示正常程序的关闭,执行的是以下操作:System.exit(0);
    				default:
    					System.out.println("输入出错!请重新输入");
    					break;// 表示正常程序的关闭,执行的是以下操作:System.exit(0);
    			}
    		}
    		System.out.println("感谢您对本系统的使用,欢迎下次继续使用");
    	}
    
    }
    
    
    package StudentDemo;
    
    public class Student {
    	private String stuNum;//学号
    	private String name;//姓名
    	private String gender;//性别
    	private int age;//年龄
    	private int score;//分数
    	public Student() {
    		super();
    	}
    	public Student(String stuNum,String name,String gender,int age,int score) {
    		this.stuNum = stuNum;
    		this.name = name;
    		this.gender = gender;
    		this.age = age;
    		this.score = score;
    	}
    
    
    	public String getStuNum() {
    		return stuNum;
    	}
    	public void setStuNum(String stuNum) {
    		this.stuNum = stuNum;
    	}
    	public String getName() {
    		return name;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    	public String getGender() {
    		return gender;
    	}
    	public void setGender(String gender) {
    		this.gender = gender;
    	}
    	public int getAge() {
    		return age;
    	}
    	public void setAge(int age) {
    		this.age = age;
    	}
    	public int getScore() {
    		return score;
    	}
    	public void setScore(int score) {
    		this.score = score;
    	}
    
    }
    
    
    
    package StudentDemo;
    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.List;
    import java.util.Scanner;
    
    public class Tools_ArrayList {
    
    	static ArrayList<Student> stus = new ArrayList<Student>();
    
    	static Scanner scanner = new Scanner(System.in);
    
    	public static void add() {// 添加学生信息
    
    		System.out.println("添加时要输入学生的学号,姓名,性别,年龄,成绩");
    		Student stu = new Student();
    		System.out.println("请输入该学生的学号:");
    		stu.setStuNum(scanner.next());
    		System.out.println("请输入该学生的姓名:");
    		stu.setName(scanner.next());
    		System.out.println("请输入该学生的性别:");
    		stu.setGender(scanner.next());
    		System.out.println("请输入该学生的年龄:");
    		stu.setAge(scanner.nextInt());
    		System.out.println("请输入该学生的成绩:");
    		stu.setScore(scanner.nextInt());
    		stus.add(stu);
    		System.out.println("添加成功");
    
    	}
    
    	public static void show() {// 展示学生信息
    		System.out.println("*******************************************");
    		System.out.println(" 学号             姓名                          性别              年龄                成绩");
    		for (int i = 0; i < stus.size(); i++){
    			System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + "\t" + stus.get(i).getGender() + "\t"
    					+ stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    		}
    		System.out.println("*******************************************");
    		System.out.println();
    	}
    
    	// 这里排序调用api方法
    	public static void paixu(){
    		Collections.sort(stus, new Comparator<Student>(){
    			@Override
    			public int compare(Student stu1, Student stu2) {
    				if(stu1.getScore()>stu2.getScore()){
    					return 1;
    				}else if(stu1.getScore()==stu2.getScore()){
    					return 0;
    				}else{
    					return -1;
    				}
    			}
    		});
    
    	}
    
    	public static void change() {// 改变学生信息
    		System.out.println("请输入要修改信息的学生学号");
    		String stunumber = scanner.next();
    		for (int i = 0; i < stus.size(); i++) {
    			if (stunumber.equals(stus.get(i).getStuNum())) {
    				System.out.println("请输入要修改的学生的信息,学号,姓名,性别,年龄,分数");
    				stus.get(i).setStuNum(scanner.next());
    				stus.get(i).setName(scanner.next());
    				stus.get(i).setGender(scanner.next());
    				stus.get(i).setAge(scanner.nextInt());
    				stus.get(i).setScore(scanner.nextInt());
    				break;
    			}
    
    		}
    	}
    
    	public static void query() {// 查询
    		System.out.println("请输入要查询的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < stus.size(); i++) {
    			if (Stunumber.equals(stus.get(i).getStuNum())) {
    				System.out.println("*******************************************");
    				System.out.println(" 学号             姓名                          性别              年龄                成绩");
    				System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + "\t" + stus.get(i).getGender()
    						+ "\t" + stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    				System.out.println("*******************************************");
    			}
    		}
    
    	}
    
    	public static void delete() {// 删除学生信息
    		System.out.println("请输入要删除信息的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < stus.size(); i++) {
    			if (Stunumber.equals(stus.get(i).getStuNum())) {
    				stus.remove(i);
    			}
    		}
    		System.out.println("删除完成");
    	}
    
    
    }
    
    package StudentDemo;
    
    import java.util.Scanner;
    
    public class Tools_Arrays {
    	// 定义学生数组,容量为100
    	static Student[] stus = new Student[100];
    	// 数据中实际添加学生的下标,每添加一个下标加1,删除时减1,留意下面的add(),delete()
    	static int number = 0;
    	static Scanner scanner = new Scanner(System.in);
    
    	public static void add() {// 添加学生信息
    
    		System.out.println("添加时要输入学生的学号,姓名,性别,年龄,成绩");
    		stus[number] = new Student();
    		System.out.println("请输入该学生的学号:");
    		stus[number].setStuNum(scanner.next());
    		System.out.println("请输入该学生的姓名:");
    		stus[number].setName(scanner.next());
    		System.out.println("请输入该学生的性别:");
    		stus[number].setGender(scanner.next());
    		System.out.println("请输入该学生的年龄:");
    		stus[number].setAge(scanner.nextInt());
    		System.out.println("请输入该学生的成绩:");
    		stus[number].setScore(scanner.nextInt());
    		// 添加成功,下标加1
    		number++;
    		System.out.println("添加成功");
    
    	}
    
    	public static void show() {// 展示学生信息
    		System.out.println("*******************************************");
    		System.out.println(" 学号             姓名                          性别              年龄                成绩");
    		for (int i = 0; i < number; i++)
    			System.out.println(stus[i].getStuNum() + "\t" + stus[i].getName() + "\t" + "\t" + stus[i].getGender() + "\t"
    					+ stus[i].getAge() + "\t" + stus[i].getScore());
    		System.out.println("*******************************************");
    		System.out.println();
    	}
    
    	// 这里排序用的是冒泡排序,在练习时,可以使用十大排序的任意一种替换。
    	public static void paixu() {// 对学生信息进行排序
    		int j;
    		Student temp = new Student();
    		for (int i = 0; i < number; i++) {
    			for (j = i + 1; j < number; j++)
    				if (stus[i].getScore() > stus[j].getScore()) {
    					temp = stus[i];
    					stus[i] = stus[j];
    					stus[j] = temp;
    				}
    		}
    		System.out.println("排序完成,选择”学生信息查看“进行查看");
    	}
    
    	public static void change() {// 改变学生信息
    		System.out.println("请输入要修改信息的学生学号");
    		String Stunumber = scanner.next();
    		for (int i = 0; i < number; i++) {
    			if (Stunumber.equals(stus[i].getStuNum())) {
    				System.out.println("请输入要修改的学生的信息,学号,姓名,性别,年龄,分数");
    				stus[i].setStuNum(scanner.next());
    				stus[i].setName(scanner.next());
    				stus[i].setGender(scanner.next());
    				stus[i].setAge(scanner.nextInt());
    				stus[i].setScore(scanner.nextInt());
    				break;
    			}
    
    		}
    	}
    
    	public static void query() {// 查询
    		System.out.println("请输入要查询的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < number; i++) {
    			if (Stunumber.equals(stus[i].getStuNum())) {
    				System.out.println("*******************************************");
    				System.out.println(" 学号             姓名                          性别              年龄                成绩");
    				System.out.println(stus[i].getStuNum() + "\t" + stus[i].getName() + "\t" + "\t" + stus[i].getGender()
    						+ "\t" + stus[i].getAge() + "\t" + stus[i].getScore());
    				System.out.println("*******************************************");
    			}
    		}
    
    	}
    
    	public static void delete() {// 删除学生信息
    		System.out.println("请输入要删除信息的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < number; i++) {
    			if (Stunumber.equals(stus[i].getStuNum()))
    				break;
    		}
    
    		for (; i < number - 1; i++) {
    			stus[i] = stus[i + 1];
    		}
    
    		number--;
    
    		System.out.println("删除完成");
    	}
    
    }
    
    package StudentDemo;
    
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Scanner;
    
    public class Tools_DB {
    
    	static ArrayList<Student> stus = new ArrayList<Student>();
    
    	static Scanner scanner = new Scanner(System.in);
    
    	public static void dbExcute(String sql) {
    		ResultSet rs = null;
    		Statement stmt = null;
    		Connection conn = null;
    		try {
    			/* 加载并注册MySQL的JDBC驱动 */
    			Class.forName("com.mysql.jdbc.Driver");
    			/* 建立到MySQL数据库的建立 */
    			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useSSL = false&useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC",
    					"root", "hui768285131");
    			// conn=DriverManager.getConnection("jdbc:mysql://120.26.208.137:3306/db_test?characterEncoding=utf8","db_test","123qwe!@#");
    			/* 访问数据库,执行SQL语句 */
    			stmt = conn.createStatement();
    			stmt.executeUpdate(sql);
    
    		} catch (ClassNotFoundException e) {
    			e.printStackTrace();
    		} catch (SQLException e) {
    			e.printStackTrace();
    		} finally {
    			try {
    				if (rs != null) {
    					rs.close();// 关闭ResultSet对象
    					rs = null;
    				}
    				if (stmt != null) {
    					stmt.close();// 关闭Statement对象
    					stmt = null;
    				}
    				if (conn != null) {
    					conn.close();// 关闭Connection对象
    					conn = null;
    				}
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}
    		}
    	}
    
    	public static void query(String sql) {
    		ResultSet rs = null;
    		Statement stmt = null;
    		Connection conn = null;
    		try {
    			/* 加载并注册MySQL的JDBC驱动 */
    			Class.forName("com.mysql.jdbc.Driver");
    			/* 建立到MySQL数据库的建立 */
    			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?useSSL = false&useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC",
    					"root", "hui768285131");
    			// conn=DriverManager.getConnection("jdbc:mysql://120.26.208.137:3306/db_test?characterEncoding=utf8","db_test","123qwe!@#");
    			/* 访问数据库,执行SQL语句 */
    			stmt = conn.createStatement();
    			/* 添加记录 */
    			System.out.println("添加记录后:");
    			// rs=stmt.executeQuery("select * from student");
    			rs = stmt.executeQuery(sql);
    			stus = new ArrayList<Student>();
    
    			while (rs.next()) {
    
    				String stuNum = rs.getString("stuNum");
    				String name = rs.getString("name");
    				String gender = rs.getString("gender");
    				int age = rs.getInt("age");
    				int score = rs.getInt("score");
    
    				Student student = new Student();
    				student.setStuNum(stuNum);
    				student.setName(name);
    				student.setGender(gender);
    				student.setAge(age);
    				student.setScore(score);
    
    				stus.add(student);
    
    			}
    
    		} catch (ClassNotFoundException e) {
    			e.printStackTrace();
    		} catch (SQLException e) {
    			e.printStackTrace();
    		} finally {
    			try {
    				if (rs != null) {
    					rs.close();// 关闭ResultSet对象
    					rs = null;
    				}
    				if (stmt != null) {
    					stmt.close();// 关闭Statement对象
    					stmt = null;
    				}
    				if (conn != null) {
    					conn.close();// 关闭Connection对象
    					conn = null;
    				}
    			} catch (SQLException e) {
    				e.printStackTrace();
    			}
    		}
    	}
    
    	public static void add() {// 添加学生信息
    
    		System.out.println("添加时要输入学生的学号,姓名,性别,年龄,成绩");
    		System.out.println("请从键盘输入学号");
    		String outter_stuNum = scanner.next();
    
    		System.out.println("请从键盘输入姓名");
    		String outter_name = scanner.next();
    
    		System.out.println("请从键盘输入性别");
    		String outter_gender = scanner.next();
    
    		System.out.println("请输入该学生的年龄:");
    		int outter_age = scanner.nextInt();
    
    		System.out.println("请从键盘输入成绩");
    		int outter_score = scanner.nextInt();
    
    		String sql = "insert into student_jxyy(stuNum,name,gender,age,score) values(" + "'" + outter_stuNum + "','"
    				+ outter_name + "','" + outter_gender + "'," + outter_age + "," + outter_score + ")";
    		System.out.println(sql);
    		dbExcute(sql);
    
    		System.out.println("添加成功");
    
    	}
    
    	public static void show() {// 展示学生信息
    
    		// 从数据库中查询出数据
    		query("select * from student_jxyy");
    
    		System.out.println("*******************************************");
    		System.out.println(" 学号               姓名                 性别               年龄              成绩");
    		for (int i = 0; i < stus.size(); i++)
    			System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + stus.get(i).getGender()
    					+ "\t" + stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    		System.out.println("*******************************************");
    		System.out.println();
    
    	}
    
    	// 这里排序调用api方法
    	@SuppressWarnings("unchecked")
    	public static void paixu() {
    		// 从数据库中查询出数据
    		query("select * from student_jxyy order by score");
    		System.out.println("*******************************************");
    		System.out.println(" 学号        姓名            性别          年龄         成绩");
    		for (int i = 0; i < stus.size(); i++)
    			System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + "\t"
    					+ stus.get(i).getGender() + "\t" + stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    		System.out.println("*******************************************");
    		System.out.println();
    
    	}
    
    	public static void change() {// 改变学生信息
    
    		System.out.println("请输入要修改的学生的信息,学号,姓名,性别,年龄,分数");
    
    		System.out.println("请从键盘输入学号");
    		String outter_stuNum = scanner.next();
    		System.out.println("请从键盘输入姓名");
    		String outter_name = scanner.next();
    		System.out.println("请从键盘输入性别");
    		String outter_gender = scanner.next();
    		System.out.println("请输入该学生的年龄:");
    		int outter_age = scanner.nextInt();
    		System.out.println("请从键盘输入成绩");
    		int outter_score = scanner.nextInt();
    
    		StringBuffer sql = new StringBuffer(" update student_jxyy ");
    		sql.append(" set name = ");
    		sql.append("'" + outter_name + "', ");
    		sql.append("  gender = ");
    		sql.append("'" + outter_gender + "', ");
    		sql.append("  age = ");
    		sql.append(outter_age + ", ");
    		sql.append("  score = ");
    		sql.append(outter_score + " ");
    		sql.append(" where stuNum = " + "'" + outter_stuNum + "'");
    		System.out.println(sql);
    		// dbExcute(sql.toString());
    
    	}
    
    	public static void query() {// 查询
    		// 从数据库中查询出数据
    		System.out.println("请输入要查询的学生学号");
    		String stunumber = scanner.next();
    		query("select * from student_jxyy where stuNum = " + "'" + stunumber + "'");
    		for (int i = 0; i < stus.size(); i++) {
    
    			System.out.println("*******************************************");
    			System.out.println(" 学号        姓名                               性别          年龄         成绩");
    			System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + stus.get(i).getGender()
    					+ "\t" + stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    			System.out.println("*******************************************");
    
    		}
    
    	}
    
    	public static void delete() {// 删除学生信息
    		System.out.println("请输入要删除信息的学生学号");
    		String stunumber = scanner.next();
    
    		StringBuffer sql = new StringBuffer(" delete from student_jxyy ");
    
    		sql.append(" where stuNum = " + "'" + stunumber + "'");
    		System.out.println(sql);
    		dbExcute(sql.toString());
    
    		System.out.println("删除完成");
    	}
    
    }
    
    package StudentDemo;
    
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.Comparator;
    import java.util.List;
    import java.util.Scanner;
    
    public class  Tools_IOFile{
    
    	static ArrayList<Student> stus = new ArrayList<Student>();
    
    	static Scanner scanner = new Scanner(System.in);
    
    	public static void addToFile(String str)  {
    		PrintWriter out;
    		try {
    			out = new PrintWriter(new FileOutputStream("students.txt",true));
    			out.write(str);
    			out.write("\n");
    			out.close();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}
    
    
    
    
    	public static void add() {
    
    
    		System.out.println("添加时要输入学生的学号,姓名,性别,年龄,成绩");
    		System.out.println("请从键盘输入学号");
    		String outter_stuNum = scanner.next();
    
    
    		System.out.println("请从键盘输入姓名");
    		String outter_name = scanner.next();
    
    		System.out.println("请从键盘输入性别");
    		String outter_gender = scanner.next();
    
    		System.out.println("请输入该学生的年龄:");
    		int outter_age = scanner.nextInt();
    
    		System.out.println("请从键盘输入成绩");
    		int outter_score = scanner.nextInt();
    
    
    		String studentInfo = outter_stuNum + ":" + outter_name + ":" + outter_gender + ":" +outter_age + ":" + outter_score;
    		addToFile(studentInfo);
    		System.out.println("添加成功");
    
    	}
    
    	/**
    	 * 将文本中学生信息加载入容器
    	 */
    	public static ArrayList<Student> txtInfoToList() {
    
    		ArrayList<Student> stuList = new ArrayList<Student>();
    		try {
    			BufferedReader in = new BufferedReader(new FileReader("students.txt"));
    			String info = null;
    			while((info = in.readLine()) != null){
    				String[] infos = info.split(":");
    				if (infos != null && infos.length == 5){
    					Student stu = new Student();
    					// 学号,姓名,性别,年龄,成绩
    					stu.setStuNum(infos[0]);
    					stu.setName(infos[1]);
    					stu.setGender(infos[2]);
    					stu.setAge(Integer.parseInt(infos[3]));
    					stu.setScore(Integer.parseInt(infos[4]));
    					stuList.add(stu);
    				}
    			}
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}  catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		return stuList;
    
    	}
    	/**
    	 * 将容器中学生信息写入文本
    	 */
    	public static void listInfoToTxt(ArrayList<Student> stuList){
    		// 将动态组的内容写入到文件
    		try {
    			PrintWriter out = new PrintWriter(new FileOutputStream("students.txt"),false);
    
    			for (int i = 0;i < stuList.size();i++) {
    
    				String stuNum = stuList.get(i).getStuNum();
    
    				String name = stuList.get(i).getName();
    
    				String gender = stuList.get(i).getGender();
    
    				int age = stuList.get(i).getAge();
    
    				int score = stuList.get(i).getScore();
    
    
    				String studentInfo =stuNum + ":" + name + ":" + gender + ":" + age + ":" + score;
    				addToFile(studentInfo);
    
    			}
    			out.close();
    		} catch (FileNotFoundException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    
    	}
    
    
    	public static void show() {// 展示学生信息
    
    		// 让stus重新指向文本中的学生信息
    		stus =  txtInfoToList();
    
    		System.out.println("*******************************************");
    		System.out.println(" 学号             姓名                          性别              年龄                成绩");
    		for (int i = 0; i < stus.size(); i++)
    			System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + "\t" + stus.get(i).getGender() + "\t"
    					+ stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    		System.out.println("*******************************************");
    		System.out.println();
    	}
    
    	// 这里排序调用api方法
    	@SuppressWarnings("unchecked")
    	public static void paixu(){
    
    		// 让stus重新指向文本中的学生信息
    		stus =  txtInfoToList();
    
    		Collections.sort(stus, new Comparator(){
    			@Override
    			public int compare(Object o1, Object o2) {
    				Student stu1=(Student)o1;
    				Student stu2=(Student)o2;
    				if(stu1.getScore()>stu2.getScore()){
    					return 1;
    				}else if(stu1.getScore()==stu2.getScore()){
    					return 0;
    				}else{
    					return -1;
    				}
    			}
    		});
    
    		// 将容器中学生信息写入文本
    		listInfoToTxt(stus);
    	}
    
    
    	public static void change() {// 改变学生信息
    
    		// 让stus重新指向文本中的学生信息
    		stus =  txtInfoToList();
    
    		System.out.println("请输入要修改信息的学生学号");
    		String Stunumber = scanner.next();
    		for (int i = 0; i < stus.size(); i++) {
    			if (Stunumber.equals(stus.get(i).getStuNum())) {
    				System.out.println("请换行输入要修改的学生的信息:姓名,性别,年龄,分数");
    				stus.get(i).setName(scanner.next());
    				stus.get(i).setGender(scanner.next());
    				stus.get(i).setAge(scanner.nextInt());
    				stus.get(i).setScore(scanner.nextInt());
    				break;
    			}
    
    		}
    		// 将容器中学生信息写入文本
    		listInfoToTxt(stus);
    	}
    
    
    	public static void query() {// 查询
    
    		// 让stus重新指向文本中的学生信息
    		stus =  txtInfoToList();
    
    		System.out.println("请输入要查询的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < stus.size(); i++) {
    			if (Stunumber.equals(stus.get(i).getStuNum())) {
    				System.out.println("*******************************************");
    				System.out.println(" 学号             姓名                          性别              年龄                成绩");
    				System.out.println(stus.get(i).getStuNum() + "\t" + stus.get(i).getName() + "\t" + "\t" + stus.get(i).getGender()
    						+ "\t" + stus.get(i).getAge() + "\t" + stus.get(i).getScore());
    				System.out.println("*******************************************");
    			}
    		}
    
    	}
    
    	public static void delete() {// 删除学生信息
    
    		// 让stus重新指向文本中的学生信息
    		stus =  txtInfoToList();
    
    		System.out.println("请输入要删除信息的学生学号");
    		String Stunumber = scanner.next();
    		int i;
    		for (i = 0; i < stus.size(); i++) {
    			if (Stunumber.equals(stus.get(i).getStuNum())) {
    				stus.remove(i);
    			}
    		}
    
    		// 将容器中学生信息写入文本
    		listInfoToTxt(stus);
    		System.out.println("删除完成");
    	}
    
    
    }
    
    

    需要idea连接MySQL数据库创建test

    需要test数据库和student_jxyy表

    在这里插入图片描述
    细节:idea连接MySQL数据库创建test时需要注意MySQL的版本要对应的连接
    在这里插入图片描述
    还有/* 加载并注册MySQL的JDBC驱动 */
    mysql 5.x : Class.forName(“com.mysql.jdbc.Driver”);
    mysql 5.x以上 :Class.forName(“com.mysql.cj.jdbc.Driver”);
    在这里插入图片描述
    上面的test就是数据库名称,你的不一样可以改

    展开全文
  • 文章目录项目链接展示router路由设计思路代码npm配置app.js 服务启动入口db.json 学生数据router.js 路由student.js 功能封装index.html 主页面new.html 添加edit.html 编辑 项目链接 ...展示 router路由设计思路 ...
  • 详细安装步骤:https://www.cnblogs.com/wodekaifalog/p/10832094.html 将数据库脚本导入安装好的MySQL中 二、 安装Python3 详细安装步骤:https://www.cnblogs.com/weven/p/7252917.html 三、 通过python3的pip...
  • 学生管理系统

    2019-03-14 10:48:56
    适合一些刚刚毕业的同学拿去试手,学生管理系统 步骤如下: A:定义学生类 B:学生管理系统的主界面的代码编写 C:学生管理系统的查看所有学生的代码编写 D:学生管理系统的添加学生的代码编写 E:学生管理系统的删除学生...
  • 简单的Java学生信息管理系统

    千次阅读 2018-11-29 21:57:25
    简单的Java学生管理系统,这个系统只是一些简单的操作,包含一个学生类和一个测试类。 学生类包含一些简单的数据,将成员变量设置为私有的,再用方法去调用。 学生类: package studentImformation; public ...
  • 本项目使用JDBC连接技术,实现登录后陈列数据库中全部人员信息的简单管理系统,在JDBC这里有问题的可以下载作为参考,附数据库!
  • django学生信息管理系统,功能完整,完整。
  • 支持学生信息的增、删、改、查,可以根据学号,姓名进行模糊查询,可以排序
  • java基础连接MySQL数据库,实现一个简单的学生信息管理,全部是控制台输出,java基础学习,简单的javase,全部是基础
  • 空间数据库实习,课程设计均可使用,仅供参考(只适合于初级)
  • 学生管理包含了学生信息的增删改查,这里我只讲最重要的根据模板导入和导出。 前端代码 <div> <div class="search-div"> <div class=""> <div class="layui-inlin...
  • 学生管理系统(JAVA+GUI+IO);JAVA-学生管理系统(最简单的SWING+IO读写文件持久化数据)详细代码及步骤
  • 用java做的界面,MySQL作为后台数据库,可以实现对学生表的增删改查
  • 基于python与mysql的学生成绩管理系统 代码简单 已达包 界面简洁 有文档 图片 设计步骤等 主要基于tkinter库与pymysql库设计的GUI 界面程序
  • 学生成绩管理系统使用Java GUI和MySQL数据库以及相关知识,分为管理员、教师用户和学生用户三种登录方式,主要的功能就是对学生的成绩进行管理和查询。
  • 学生信息管理系统制作步骤.ppt

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 46,019
精华内容 18,407
关键字:

学生管理系统步骤