国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

這篇具有很好參考價值的文章主要介紹了java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

?? ?? 本期帶領大家一起來學習java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫的實現(xiàn)思路 ?? ??

題目要求+數(shù)據(jù)庫??

學生信息包括:學號,姓名,年齡,性別,出生年月,地址,電話,E-mail等。試設計學生信息管理系統(tǒng),使之能提供以下功能:
1、系統(tǒng)以菜單方式工作
2、學生信息錄入功能--輸入
3、學生信息瀏覽功能--輸出
4、學生信息查詢功能--算法
按學號查詢
按姓名查詢
5、學生信息的刪除與修改(可選項)

java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

一 、環(huán)境搭建??

在idea創(chuàng)建一個工程文件,在工程文件下創(chuàng)建一個model模塊,在model模塊下創(chuàng)建一個classSystem包,然后再存放對應的類,如下圖所示
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫
需要注意是因為連接了數(shù)據(jù)庫,所以需要導入相應的jar包

二 、功能實現(xiàn) ?? ??

1.學生信息類的創(chuàng)建?

首先實現(xiàn)這個學生信息管理系統(tǒng),我們需要先創(chuàng)建一個學生信息類
,包括學生的學號,姓名,年齡,地址,電話,郵箱,出生日期,具體代碼如下?? ?? ??

package classSystem;


public class Student {
    private int stuId;
    private String name;
    private int age;

    private String sex;
    private String birth;

    private String address;
    private String tel;
    private String Email;


    public Student() {
    }

    public Student(int stuId, String name, int age, String sex, String birth, String address, String tel, String email) {
        this.stuId = stuId;
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.birth = birth;
        this.address = address;
        this.tel = tel;
        Email = email;
    }

    public int getStuId() {
        return stuId;
    }

    public void setStuId(int stuId) {
        this.stuId = stuId;
    }

    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;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirth() {
        return birth;
    }

    public void setBirth(String birth) {
        this.birth = birth;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getEmail() {
        return Email;
    }

    public void setEmail(String email) {
        Email = email;
    }
}


2.學生信息的添加功能??

?? ??因為這個學生信息管理系統(tǒng)的java程序是連接了數(shù)據(jù)庫,所以我們在錄入我們的信息的時候,需要講我們所錄入的學生信息存放到數(shù)據(jù)庫當中,所以我們需要運用到sql語句
去添加我們所錄入的信息,做到了隨時隨地可以查詢,更好地管理我們的學生信息?? ??

public static void addStu(ArrayList<Student> stu) throws AWTException {
        while (true) {
            Extents.clearConsole();
            System.out.println(">首界面>功能界面>添加學生信息\n\n");
            Scanner sc = new Scanner(System.in);
            System.out.print("請輸入學生學號(例:2022): ");
            int stuId=sc.nextInt();
            System.out.print("請輸入學生姓名(例:張三): ");
            String name = sc.next();
            System.out.print("請輸入學生年齡(例:18): ");
            int age = sc.nextInt();
            System.out.print("請輸入學生性別(例:男): ");
            String sex =sc.next();
            System.out.print("請輸入學生出生日期(例:2004-6-1): ");
            String birth =sc.next();
            System.out.print("請輸入學生電話(例:123456): ");
            String tel=sc.next();
            System.out.print("請輸入學生email(例:123456@qq.com): ");
            String emial =sc.next();
            System.out.print("請輸入學生地址(例:深圳): ");
            String address = sc.next();

            System.out.println("\n\n-----------------------------------------------------");
            System.out.println( "\t\t學號: "+stuId+"\t\t姓名: " + name + "\t\t年齡: " + age + "\t\t地址: " + address
            +"\t\t性別: " +sex+"\t\t出生日期: " +birth+"\t\t地址: " +address+"\t\t電話: " +tel+"\t\t郵箱: " +emial);
            System.out.print("\n\n是否添加該學生信息? [Yes(1) / No(0)] :");
            Extents.isAdd(stu, sc, stuId,sex,birth,tel,emial, name, age, address);
            System.out.println("\n\n\n>首界面>功能界面>添加學生信息\n");
            System.out.println("\t                繼續(xù)添加                   請輸入1               ");
            System.out.println();
            System.out.println("\t                返回上級                   請輸入0               ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.print("\n請輸入您的選擇:");
            while (true) {
                int choose = sc.nextInt();
                if (choose == 1) {
                    break;
                } else if (choose == 0) {
                    Extents.clearConsole();
                    return;
                } else {
                    System.out.print("看清選項! 再給你一次機會: ");
                }
            }
        }
    }

public static void isAdd(ArrayList<Student> stu, Scanner sc,int stuId ,String sex,String birth,String tel,String email, String name, int age, String address) throws AWTException {
        while (true) {
            int is = sc.nextInt();
            if (is == 0) {
                Extents.clearConsole();
                System.out.println("取消成功!");
                break;
            } else if (is == 1) {
                /*Student s = new Student(stuId,name, age,sex,birth, address,tel,email);
                stu.add(s);*/
                Connection connection =null;

                String sql ="insert into Student values(?,?,?,?,?,?,?,?)";
                PreparedStatement preparedStatement=null;
                try {

                    connection  = jdbcUtiles.getConnection();
                    preparedStatement = connection.prepareStatement(sql);

                   preparedStatement.setInt(1,stuId);
                   preparedStatement.setString(2,name);
                   preparedStatement.setInt(3,age);
                   preparedStatement.setString(4,sex);
                   preparedStatement.setString(5,address);
                   preparedStatement.setString(6,birth);
                   preparedStatement.setString(7,tel);
                   preparedStatement.setString(8,email);

                    //執(zhí)行
                    preparedStatement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }finally {
                    jdbcUtiles.close(null,preparedStatement,connection);
                }


                stuId += 1;
                Extents.clearConsole();
                System.out.println("添加信息成功!\n\n");
                FunctionalBlock.showStu(stu);
                break;
            }
            System.out.print("\n輸入錯誤!請重新輸入:");
        }
    }

相信大家看到這里會有點迷惑,那么現(xiàn)在我來梳理一下增加信息代碼塊的實現(xiàn)邏輯
首先我們先在FunctionalBlock當中的addStudan當中錄入我們的信息?? ??
然后再調用我們Extens當中的isAdd判斷是否錄入我們的信息
如果錄入信息的話,使用sql語句進行與數(shù)據(jù)庫的連接,并且將信息錄入到數(shù)據(jù)庫當中
并且會查詢數(shù)據(jù)庫當中的信息?? ??
如果不錄入信息的話,那么就取消錄入

增加學生信息效果圖如下
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

3.學生信息的刪除功能???

學生信息的刪除功能的實現(xiàn),先調用FunctionalBlock
當中的showStu的方法展示全部學生的信息????
再選擇需要刪除的學生信息????
同樣先要判斷所輸入的學號是=是否存在,用到了Extents當中的getFlag的方法
如果不存在,則返回-1,存在的話則進行刪除操作
同樣用到了sql語句與數(shù)據(jù)庫當中的學生信息進行了交互??

public static void deleteStu(ArrayList<Student> stu) throws AWTException {
        Scanner sc = new Scanner(System.in);
        showStu(stu);
        while (true) {
            System.out.print("\n請輸入要刪除的學生學號:");
            int sid = sc.nextInt();
            sc.nextLine();
            int flag = Extents.getFlag(stu, sid);
            if (flag == -1) {
                System.out.print("\n該學號不存在,請重新輸入\n");
            } else {
                System.out.print("\n是否刪除學號為:" + sid + " 的學生信息? [Yes(1) / No(0)] :");
                Extents.isDlete(stu, sc, flag);
                System.out.println("\n\n\n>首界面>功能界面>刪除學生信息\n");
                System.out.println("\t                繼續(xù)刪除                   請輸入1                ");
                System.out.println();
                System.out.println("\t                返回上級                   請輸入0                ");
                System.out.println("\t ----------------------------------------------------------------");
                System.out.print("\n請輸入您的選擇: ");
                while (true) {
                    int choose = sc.nextInt();
                    if (choose == 1) {
                        break;
                    } else if (choose == 0) {
                        Extents.clearConsole();
                        return;
                    } else {
                        System.out.print("看清選項! 再給你一次機會: ");
                    }
                }
            }
        }
    }

刪除學生信息效果圖如下

java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

4.學生信息的修改功能 ????

修改學生信息的功能呢,和上面刪除學生信息 功能的實現(xiàn)類似,我們同樣來看看如何實現(xiàn)的
學生信息的修改功能的實現(xiàn),先調用FunctionalBlock當中的showStu的方法展示全部學生的信息
再選擇需要修改的學生學號?? ??? ?
同樣先要判斷所輸入的學號是=是否存在,用到了Extents當中的getFlag的方法
如果不存在,則返回-1,存在的話則進行修改操作
再然后輸入修改之后的學生信息????
同樣用到了sql語句與數(shù)據(jù)庫當中的學生信息進行了交互

 public static void updateStu(ArrayList<Student> stu) throws AWTException {
        Scanner sc = new Scanner(System.in);
        while (true) {
            showStu(stu);
            System.out.print("\n\n請輸入要修改信息的學生學號:");
            int sidUpdate = sc.nextInt();
            int flag = Extents.getFlag(stu, sidUpdate);
            Extents.clearConsole();
            if (flag == -1) {
                System.out.print("該學號不存在,請重新輸入\n\n\n ");
            } else {
                System.out.println(">首界面>功能界面>修改學生信息\n\n");
                System.out.print("請輸入學生學號(例:2022: ");
                int id=sc.nextInt();
                System.out.print("請輸入學生姓名(例:張三): ");
                String name = sc.next();
                System.out.print("請輸入學生年齡(例:18): ");
                int age = sc.nextInt();
                System.out.print("請輸入學生性別(例:男): ");
                String sex =sc.next();
                System.out.print("請輸入學生出生日期(例:2004-6-1): ");
                String birth =sc.next();
                System.out.print("請輸入學生電話(例:123456): ");
                String tel=sc.next();
                System.out.print("請輸入學生email(例:123456@qq.com): ");
                String emial =sc.next();
                System.out.print("請輸入學生地址(例:深圳): ");
                String address = sc.next();
                Extents.clearConsole();
                Extents.getFlag(stu, sidUpdate);


                Connection connection =null;
                String sql ="update Student set stuId=? ,name=?,age=?,sex=?,adress=?,birth=?,tel=?,Email=?where stuId=?";
                PreparedStatement preparedStatement=null;
                try {
                    connection  = jdbcUtiles.getConnection();
                    preparedStatement = connection.prepareStatement(sql);
                    preparedStatement.setInt(1,id);
                    preparedStatement.setString(2,name);
                    preparedStatement.setInt(3,age);
                    preparedStatement.setString(4,sex);
                    preparedStatement.setString(5,address);
                    preparedStatement.setString(6,birth);
                    preparedStatement.setString(7,tel);
                    preparedStatement.setString(8,emial);
                    preparedStatement.setInt(9,flag);

                    //執(zhí)行
                    preparedStatement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }finally {
                    jdbcUtiles.close(null,preparedStatement,connection);
                }




                System.out.println(">首界面>功能界面>修改學生信息");
                System.out.println("\n\n------------------------------------------------------------------");

                System.out.println("修改后——>\n");
                System.out.println( "\t\t姓名: " + name + "\t\t年齡: " + age + "\t\t地址: " + address
                        +"\t\t性別: " +sex+"\t\t出生日期: " +birth+"\t\t地址: " +address+"\t\t電話: " +tel+"\t\t郵箱: " +emial);
                System.out.print("\n\n是否修改該學生信息? [Yes(1) / No(0)] :");
                Extents.isUpdata(stu, sc, sidUpdate, flag,sex,birth,tel,emial, name, age, address);
                System.out.println("\n\n\n>首界面>功能界面>修改學生信息\n");
                System.out.println("\t                繼續(xù)修改                   請輸入1              ");
                System.out.println();
                System.out.println("\t                返回上級                   請輸入0              ");
                System.out.println("\t --------------------------------------------------------------");
                System.out.print("\n請輸入您的選擇:");
                while (true) {
                    int choose = sc.nextInt();
                    if (choose == 1) {
                        Extents.clearConsole();
                        break;
                    } else if (choose == 0) {
                        Extents.clearConsole();
                        return;
                    } else {
                        System.out.print("看清選項! 再給你一次機會: ");
                    }
                }
            }
        }
    }

修改學生信息效果圖如下
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

5.學生信息的查看功能?????

由于查看學生信息的功能在前面三個功能當中都有調用?? ??? ?
所以我們?yōu)榱耸沟么a更加簡潔,將查詢學生信息的功能封裝起來了
避免了代碼的冗余
同樣我們來看看到底是如何實現(xiàn)的
因為我們的程序是連接了數(shù)據(jù)庫,所以我們需要查詢學生的信息的時候?? ??? ?
需要用到查詢的sql語句進行查詢,同我們的數(shù)據(jù)庫進行交互

 public static void showStu(ArrayList<Student> stu) {

        System.out.println("1.按學號查詢");
        System.out.println("2.按姓名查詢");
        System.out.println("3.查詢全部 ");
        Scanner sc =new Scanner(System.in);
        int input=sc.nextInt();
        if(input==1){
            System.out.print("輸入需要查詢的學生學號:");
            int stuid=sc.nextInt();

            Connection connection =null;
            String sql="select stuId,name,age,sex,adress,birth,tel,Email from Student where stuId=?";
            PreparedStatement preparedStatement=null;
            ResultSet set=null;
            try {
                connection  = jdbcUtiles.getConnection();
                preparedStatement = connection.prepareStatement(sql);

                preparedStatement.setInt(1,stuid);
                //執(zhí)行
                set = preparedStatement.executeQuery();

                while(set.next()){
                    int id=set.getInt("stuId");
                    String name=set.getString("name");
                    int age =set.getInt("age");
                    String sex =set.getString("sex");
                    String address=set.getString("adress");
                    String birth=set.getString("birth");
                    String tel=set.getString("tel");
                    String email=set.getString("Email");

                    System.out.println("\t\t" + id + " \t\t\t" + name
                            + " \t\t\t" + age + " \t\t\t" + sex +" \t\t\t" + address +
                            " \t\t\t" + birth+ " \t\t\t" + tel +" \t\t\t" + email +
                            "  \t\t\t"  + "\n");
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }finally {
                jdbcUtiles.close(set,preparedStatement,connection);
            }

        } else if (input==2) {


            System.out.print("輸入需要查詢的學生名字:");
            String stuname=sc.next();

            Connection connection =null;
            String sql="select stuId,name,age,sex,adress,birth,tel,Email from Student where name=?";
            PreparedStatement preparedStatement=null;
            ResultSet set=null;
            try {
                connection  = jdbcUtiles.getConnection();
                preparedStatement = connection.prepareStatement(sql);

                preparedStatement.setString(1,stuname);
                //執(zhí)行
                set = preparedStatement.executeQuery();

                while(set.next()){
                    int id=set.getInt("stuId");
                    String name=set.getString("name");
                    int age =set.getInt("age");
                    String sex =set.getString("sex");
                    String address=set.getString("adress");
                    String birth=set.getString("birth");
                    String tel=set.getString("tel");
                    String email=set.getString("Email");

                    System.out.println("\t\t" + id + " \t\t\t" + name
                            + " \t\t\t" + age + " \t\t\t" + sex +" \t\t\t" + address +
                            " \t\t\t" + birth+ " \t\t\t" + tel +" \t\t\t" + email +
                            "  \t\t\t"  + "\n");
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }finally {
                jdbcUtiles.close(set,preparedStatement,connection);
            }
        }else{
            System.out.println(">學生信息顯示\n");

            System.out.println("\t --------------------------------------------------------------------------------------------------------");
            System.out.println("\t   學號\t\t" + "   姓名\t\t" + " \t年齡\t" + "\t\t性別" + " \t\t\t地址"+
                    " \t\t\t出生日期"+" \t\t\t電話"+" \t\t\t郵箱" );
            System.out.println("\t  ------------------------------------------------------------------------------------------------------");

            Connection connection =null;
            String sql="select * from Student";
            PreparedStatement preparedStatement=null;
            ResultSet set=null;
            try {
                connection  = jdbcUtiles.getConnection();
                preparedStatement = connection.prepareStatement(sql);

                //執(zhí)行
                set = preparedStatement.executeQuery();

                while(set.next()){
                    int id=set.getInt("stuId");
                    String name=set.getString("name");
                    int age =set.getInt("age");
                    String sex =set.getString("sex");
                    String address=set.getString("adress");
                    String birth=set.getString("birth");
                    String tel=set.getString("tel");
                    String email=set.getString("Email");

                    System.out.println("\t\t" + id + " \t\t\t" + name
                            + " \t\t\t" + age + " \t\t\t" + sex +" \t\t\t" + address +
                            " \t\t\t" + birth+ " \t\t\t" + tel +" \t\t\t" + email +
                            "  \t\t\t"  + "\n");
                }
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }finally {
                jdbcUtiles.close(set,preparedStatement,connection);
            }
            System.out.println("\t  ------------------------------------" +
                    "------------------------------------------------------------------");
        }
        }

查詢學生信息效果圖如下
java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

三、主類的調用?? ?? ??

1、 登錄界面??

首先出現(xiàn)登陸的界面,我們需要輸入我們的用戶名和密碼,然后判斷是否正確
正確的話則執(zhí)行下一步操作?? ?? ??


 public static void interFace() throws AWTException {
        System.out.println(">首界面\n");
        System.out.println("\t*****************************************************************");
        System.out.println("\t                           首界面                              ");
        System.out.println("\t ---------------------------------------------------------------");
        System.out.println("\t                開始登錄                   請輸入1               ");
        System.out.println("\t ---------------------------------------------------------------");
        System.out.println("\t                退出                      請輸入0               ");
        System.out.println("\t*****************************************************************");
        Scanner sc = new Scanner(System.in);
        System.out.print("\n請輸入您的選擇: ");
        while (true) {
            int choose = sc.nextInt();
            if (choose == 1) {

                register();
                break;
            } else if (choose == 0) {
                System.out.println("退出成功!");
                System.exit(0);
            } else {
                System.out.print("看清選項! 再給你一次機會:");
            }
        }
    }
  public static void register() throws AWTException {
        for (int i = COUNT; i >= 0; i--) {
            Scanner sc = new Scanner(System.in);
            System.out.print("請輸入您的用戶名: ");
            String loginSid = sc.nextLine();
            System.out.print("請輸入您的密碼: ");
            String loginPassWd = sc.nextLine();
            if (loginSid.equals(MYSID) && loginPassWd.equals(MYPASSWD)) {
                Extents.clearConsole();
                System.out.println("歡迎登錄! 用戶:" + MYSID + "\n\n");
                menu();
                break;
            } else {
                if (i == 0) {
                    System.out.println("你是不是傻!");
                    System.exit(0);
                }
                System.out.println("錯了錯了, 你還有 " + i + " 次機會");
            }
        }
    }

2、 界面搭建????

 public static void menu() throws AWTException {
        ArrayList<Student> stu = new ArrayList<>();
        while (true) {
            System.out.println(">首界面>功能界面\n");
            System.out.println("\t*****************************************************************");
            System.out.println("\t                      歡迎來到學生管理系統(tǒng)!                      ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.println("\t                         1.添加學生信息                          ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.println("\t                         2.刪除學生信息                          ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.println("\t                         3.修改學生信息                          ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.println("\t                         4.查看學生信息                          ");
            System.out.println("\t ---------------------------------------------------------------");
            System.out.println("\t         q:返回上級菜單                  p:退出管理系統(tǒng)          ");
            System.out.println("\t******************************************************************");
            Scanner sc = new Scanner(System.in);
            System.out.print("\n請輸入您的選擇:");
            String choose = sc.nextLine();
            switch (choose) {
                case "1":
                    FunctionalBlock.addStu(stu);
                    break;
                case "2":
                    Extents.clearConsole();
                    FunctionalBlock.deleteStu(stu);
                    break;
                case "3":
                    Extents.clearConsole();
                    FunctionalBlock.updateStu(stu);
                    break;
                case "4":
                    Extents.clearConsole();
                    FunctionalBlock.showStu(stu);
                    Extents.isShow(sc);
                    break;
                case "q":
                    Extents.clearConsole();
                    interFace();
                    return;
                case "p":
                    System.out.println("退出成功!");
                    System.exit(0);
                default:
                    Extents.clearConsole();
                    System.out.println("這都錯!看清選項再選\n\n\n");
                    break;
            }
        }
    }

四、 Extents的相關善后操作?? ?? ?? ??

Extents是完成相關的善后操作,是對FunctionalBlock里面功能實現(xiàn)的相關善后的操作
目的是為了使得更加程序邏輯清晰?? ?? ??

package classSystem;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Scanner;


public class Extents {


    public static void isAdd(ArrayList<Student> stu, Scanner sc,int stuId ,String sex,String birth,String tel,String email, String name, int age, String address) throws AWTException {
        while (true) {
            int is = sc.nextInt();
            if (is == 0) {
                Extents.clearConsole();
                System.out.println("取消成功!");
                break;
            } else if (is == 1) {
                /*Student s = new Student(stuId,name, age,sex,birth, address,tel,email);
                stu.add(s);*/
                Connection connection =null;

                String sql ="insert into Student values(?,?,?,?,?,?,?,?)";
                PreparedStatement preparedStatement=null;
                try {

                    connection  = jdbcUtiles.getConnection();
                    preparedStatement = connection.prepareStatement(sql);

                   preparedStatement.setInt(1,stuId);
                   preparedStatement.setString(2,name);
                   preparedStatement.setInt(3,age);
                   preparedStatement.setString(4,sex);
                   preparedStatement.setString(5,address);
                   preparedStatement.setString(6,birth);
                   preparedStatement.setString(7,tel);
                   preparedStatement.setString(8,email);

                    //執(zhí)行
                    preparedStatement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }finally {
                    jdbcUtiles.close(null,preparedStatement,connection);
                }


                stuId += 1;
                Extents.clearConsole();
                System.out.println("添加信息成功!\n\n");
                FunctionalBlock.showStu(stu);
                break;
            }
            System.out.print("\n輸入錯誤!請重新輸入:");
        }
    }

    public static void isDlete(ArrayList<Student> stu, Scanner sc, int flag) throws AWTException {
        while (true) {
            int is = sc.nextInt();
            if (is == 0) {
                Extents.clearConsole();
                System.out.println("取消成功!");
                break;
            } else if (is == 1) {

                Connection connection =null;
                String sql ="delete from Student  where stuId=?";

                PreparedStatement preparedStatement=null;
                try {

                    connection  = jdbcUtiles.getConnection();
                    preparedStatement = connection.prepareStatement(sql);
                    preparedStatement.setInt(1,flag);

                    //執(zhí)行
                    preparedStatement.executeUpdate();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }finally {
                    jdbcUtiles.close(null,preparedStatement,connection);
                }



                Extents.clearConsole();
                System.out.println("刪除學生信息成功!\n\n");
                FunctionalBlock.showStu(stu);
                break;
            }
            System.out.print("\n輸入錯誤!請重新輸入:");
        }
    }

    public static void isUpdata(ArrayList<Student> stu, Scanner sc, int sidUpdate, int flag, String sex,String birth,String tel,String email, String name, int age, String address) throws AWTException {
        while (true) {
            int is = sc.nextInt();
            if (is == 0) {
                Extents.clearConsole();
                System.out.println("取消成功!");
                break;
            } else if (is == 1) {
                Student newStu = new Student(sidUpdate, name,age,sex,birth,address, tel,email);
                Extents.clearConsole();
                System.out.println("修改學生信息成功!\n\n");
                FunctionalBlock.showStu(stu);
                break;
            }
            System.out.print("\n輸入錯誤!請重新輸入:");
        }
    }

    public static void isShow(Scanner sc) throws AWTException {
        System.out.println("\n\n\n>首界面>功能界面>查看學生信息\n\n");
        System.out.println("\t              返回上級                     請輸入0           ");
        System.out.println("\t ---------------------------------------------------------------");
        System.out.print("\n請輸入您的選擇: ");
        while (true) {
            int choose1 = sc.nextInt();
            if (choose1 == 0) {
                Extents.clearConsole();
                break;
            } else {
                System.out.print("看清選項! 再給你一次機會: ");
            }
        }
    }

    public static int getFlag(ArrayList<Student> stu, int sid) {

        Connection connection =null;
        String sql="select * from Student";
        PreparedStatement preparedStatement=null;
        ResultSet set=null;
        try {
            connection  = jdbcUtiles.getConnection();
            preparedStatement = connection.prepareStatement(sql);

            //執(zhí)行
            set = preparedStatement.executeQuery();

            while(set.next()){

                int id  =set.getInt("stuId");
                if(sid==id){
                    return id;
                }
            }
            return -1;
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            jdbcUtiles.close(set,preparedStatement,connection);
        }




    }

    public static void clearConsole() throws AWTException {
        Robot r = new Robot();
        // 按下Ctrl鍵
        r.keyPress(KeyEvent.VK_CONTROL);
        // 按下R鍵
        r.keyPress(KeyEvent.VK_R);
        // 釋放R鍵
        r.keyRelease(KeyEvent.VK_R);
        // 釋放Ctrl鍵
        r.keyRelease(KeyEvent.VK_CONTROL);
        r.delay(50);
    }
}

五、 數(shù)據(jù)庫的連接?? ???? ?? ?? ??

畢竟我們的這個項目是要連接到數(shù)據(jù)庫當中的
?????♂? ?????♀?所以我們需要手動操作完成數(shù)據(jù)庫連接的相關代碼 ?????♂? ?????♀?

package classSystem;

import java.io.FileInputStream;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;

public class jdbcUtiles {

    //工具類,連接mysql的連接和關閉

    private static String user;
    private static String password;
    private static String url;
    private static String driver;

    static {
        Properties properties =new Properties();
        try {
            properties.load(new FileInputStream("src\\mysql.properties"));

            //讀取相關屬性
            user=properties.getProperty("uesr");
            password =properties.getProperty("password");
            url=properties.getProperty("url");
            driver = properties.getProperty("driver");


        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
    //連接數(shù)據(jù)庫

    public static Connection getConnection(){

        try {
            return DriverManager.getConnection(url,user,password);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }


    //關閉相關資源
    public static void close(ResultSet set, PreparedStatement preparedStatement,Connection connection){

        try {
            if(set!=null){
                set.close();
            }
            if(preparedStatement!=null){
                preparedStatement.close();
            }
            if(connection!=null){
                connection.close();
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }


    }

}

java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫

六 、感謝與交流?? ?? ?? ?? ?? ??

??????如果大家通過本篇博客收獲了,對通過ava實現(xiàn)學生課程管理系統(tǒng)(數(shù)據(jù)庫)
有了更好的了解的話
那么希望支持一下哦如果還有不明白的,疑惑的話,或者什么比較好的建議的話,可以發(fā)到評論區(qū),
我們一起解決,共同進步 ??????
最后謝謝大家????????????文章來源地址http://www.zghlxwxcb.cn/news/detail-475055.html

到了這里,關于java課程設計(學生信息管理系統(tǒng)設計)+數(shù)據(jù)庫的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • ASP.NET程序設計課程設計——學生信息管理系統(tǒng)

    ASP.NET程序設計課程設計——學生信息管理系統(tǒng)

    點擊查看詳細信息 ASP.NET程序設計課程設計——學生信息管理系統(tǒng) 一、實驗目的 綜合運用們所學的ASP.NET知識,開發(fā)學生信息管理系統(tǒng),完成相關功能: (1)教師管理 (2)學生信息 (3)課程信息 (4)成績管理 (5)班級管理 二、實驗環(huán)境 (1)Windows 10 (2)Visual Studio 2

    2024年02月03日
    瀏覽(32)
  • 數(shù)據(jù)庫課程設計——學生信息管理系統(tǒng)(Sqlserver,C#,Winform)

    數(shù)據(jù)庫課程設計——學生信息管理系統(tǒng)(Sqlserver,C#,Winform)

    目錄 需求分析 一.登錄功能 二.注冊功能 三.管理員登錄后跳轉到功能頁面: 四.學生信息管理(主界面,刪除功能在主界面代碼中) 五.學生信息添加和修改(設計在一個頁面上,修改需要選中行) 六.課程信息管理(刪除功能在主界面中) ?七.課程信息添加和修改 ?八.成績

    2024年02月02日
    瀏覽(28)
  • 數(shù)據(jù)庫課程設計——學生信息管理系統(tǒng)C#,SQL Sever

    數(shù)據(jù)庫課程設計——學生信息管理系統(tǒng)C#,SQL Sever

    目錄 利用SQL Sever和 VS C#實現(xiàn) 一、程序流程圖 二、具體實現(xiàn):利用SQL Sever和 VS實現(xiàn),使用C#連接數(shù)據(jù)庫 1、新建一個名為MySchool的數(shù)據(jù)庫??????? 2、C#連接數(shù)據(jù)庫,并實現(xiàn)對MySchool數(shù)據(jù)庫的增、刪、改、查操作 (1)主界面? (2)學生登錄頁面 (3)個人主頁 (4)注冊頁

    2024年01月18日
    瀏覽(29)
  • C語言課程設計:學生成績信息管理系統(tǒng)(排序、平均分、總分)詳解

    C語言課程設計:學生成績信息管理系統(tǒng)(排序、平均分、總分)詳解

    1、需求分析 利用C語言編寫一個可以對學生成績信息進行管理的系統(tǒng) 0、退出系統(tǒng) 1、錄入學生信息和成績 2、打印學生信息 3、統(tǒng)計學生人數(shù) 4、查找學生信息 5、修改學生信息 6、刪除學生信息 7、排序學生成績 8、生成學生信息文件 9、讀取文件學生信息 10、輸出各科成績不

    2024年02月11日
    瀏覽(32)
  • Java課程設計——學生成績管理系統(tǒng)

    Java課程設計——學生成績管理系統(tǒng)

    1 需求分析 1.1 需求分析概述 需求分析是開發(fā)軟件系統(tǒng)的重要環(huán)節(jié),是系統(tǒng)開發(fā)的第一步和基礎環(huán)節(jié)。通過需求分析充分認識系統(tǒng)的目標、系統(tǒng)的各個組成部分、各部分的任務職責、工作流程、工作中使用的各種數(shù)據(jù)及數(shù)據(jù)結構、各部門的業(yè)務關系和數(shù)據(jù)流程等, 為系統(tǒng)設計

    2024年02月03日
    瀏覽(23)
  • 學生信息管理系統(tǒng) Java+SQL Server 數(shù)據(jù)庫原理課程

    學生信息管理系統(tǒng) Java+SQL Server 數(shù)據(jù)庫原理課程

    該項目實現(xiàn)了圖形化界面的數(shù)據(jù)庫的登錄,以及對數(shù)據(jù)庫中表的增刪查改。 正好老師布置了相關作業(yè),通過Java 連接 SQL Server 數(shù)據(jù)庫,就寫一個學生管理系統(tǒng)。 jdk8 數(shù)據(jù)庫連接通過sqljdbc6.0 圖形化界面用swing 目錄 1、Java 連接SQL Server數(shù)據(jù)庫 2、準備數(shù)據(jù)庫 3、登錄界面 要求:

    2024年02月09日
    瀏覽(27)
  • 前端三大件html,css,js原生實現(xiàn)學生信息管理系統(tǒng)(課程設計)

    前端三大件html,css,js原生實現(xiàn)學生信息管理系統(tǒng)(課程設計)

    ? 目錄結構如該圖所示,只要將文件命名成圖上三種。代碼即可正常運行。分別有三個文件,一個是app.js,放學生信息刪除添加查詢主要邏輯代碼。login.html放登錄頁面樣式以及相關邏輯。studentList.html 放置學生管理的頁面。 運行效果圖: ? 代碼: ?app.js login頁面 studentList.

    2024年02月04日
    瀏覽(30)
  • 學生管理系統(tǒng)--課程設計項目(Java+SQL server)

    學生管理系統(tǒng)--課程設計項目(Java+SQL server)

    本科參與項目文檔合集: 點擊跳轉~ Student Management System 學校:山東科技大學 指導老師:楊 * * 教授 學號:2019032**** 學生姓名:安** 專業(yè)班級:計算機19-1 ???????????????????????????????????山東科技大學 二〇二〇年七月 1. 總體設計

    2024年02月11日
    瀏覽(23)
  • java畢業(yè)設計——基于JSP+sqlserver的學生信息管理系統(tǒng)設計與實現(xiàn)(畢業(yè)論文+程序源碼)——學生信息管理系統(tǒng)

    java畢業(yè)設計——基于JSP+sqlserver的學生信息管理系統(tǒng)設計與實現(xiàn)(畢業(yè)論文+程序源碼)——學生信息管理系統(tǒng)

    大家好,今天給大家介紹基于JSP+sqlserver的學生信息管理系統(tǒng)設計與實現(xiàn),文章末尾附有本畢業(yè)設計的論文和源碼下載地址哦。需要下載開題報告PPT模板及論文答辯PPT模板等的小伙伴,可以進入我的博客主頁查看左側最下面欄目中的自助下載方法哦 文章目錄: 隨著學校規(guī)模的

    2024年02月04日
    瀏覽(29)
  • 高校人員信息管理系統(tǒng)(Java課程設計,帶圖形界面版)

    高校人員信息管理系統(tǒng)(Java課程設計,帶圖形界面版)

    題目 1 、問題描述 某高校有四類員工:教師、實驗員、行政人員,教師兼行政人員;共有的信息包括:編號、姓名、性別、年齡等。其中,教師還包含的信息有:所在系部、專業(yè)、職稱;實驗員還包含的信息由:所在實驗室、職務;行政人員還包含的信息有:政治面貌、職稱

    2024年02月09日
    瀏覽(16)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包