Java+Eclipse+MySQL+Swing to realize the student union examination score management system (free and complete project)

Copyright notice: originality is not easy. Plagiarism and reprint are prohibited in this article. Infringement must be investigated!

 

catalogue

1, Requirements development document

2, Database design document

3, Function module part code and effect display

4, Complete source code download

5, Author Info

 

1, Requirements development document

Complete list of project documents:

 

Screenshot of requirements development document:

 

 

 

 

 

 

 

 

 

 

2, Database design document

Screenshot of database design document:

 

 

 

 

 

3, Function module part code and effect display

Database class:

 1 package system_of_database;
 2 
 3 import java.sql.Connection;
 4 import java.sql.DriverManager;
 5 import java.sql.PreparedStatement;
 6 import java.sql.ResultSet;
 7 import java.sql.SQLException;
 8 
 9 public class DBUtil {
10 
11     Connection con = null;
12     PreparedStatement ps = null;
13     ResultSet rs = null;
14 
15     public Connection getConnection() throws ClassNotFoundException,
16             SQLException,InstantiationException,IllegalAccessException {
17         String driver = "com.mysql.jdbc.Driver";
18         String url = "jdbc:mysql://localhost:3306/exam_of_students?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false";
19         String user = "root";
20         String password = "root";
21         try {
22             Class.forName(driver);
23             con = DriverManager.getConnection(url,user,password);
24             return con;
25         } catch(Exception e) {
26             throw new SQLException("Drive error or connection failure!");
27         }
28     }

 

The registration codes of candidates are as follows:

 1 public class LoginListener implements ActionListener{
 2         public void actionPerformed(ActionEvent e) {
 3             lblMsg1.setText("");
 4             lblMsg2.setText("");
 5             user = userService.findUserByName(txtName.getText().trim());
 6             if(user != null) {
 7                 if(user.getPassword().equals(new String(txtPwd.getPassword()))) {
 8                     LoginFrame_Of_Students.this.setVisible(false);
 9                     new MainFrame_Of_Students();
10                 } else {
11                     lblMsg2.setText("Password error!");
12                     txtPwd.setText("");
13                 }
14             } else {
15                 lblMsg1.setText("The candidate does not exist !");
16             }
17         }
18     }

 

The registration effect of candidates is as follows:

 

The administrator login code is as follows:

 1 public class LoginListener implements ActionListener{
 2         public void actionPerformed(ActionEvent e) {
 3             lblMsg1.setText("");
 4             lblMsg2.setText("");
 5             user = userService.findUserByName(txtName.getText().trim());
 6             if(user != null) {
 7                 if(user.getPassword().equals(new String(txtPwd.getPassword()))) {
 8                     LoginFrame_Of_Administration.this.setVisible(false);
 9                     new MainFrame_Of_Administration();
10                 } else {
11                     lblMsg2.setText("Password error!");
12                     txtPwd.setText("");
13                 }
14             } else {
15                 lblMsg1.setText("The administrator does not exist !");
16             }
17         }
18     }
19 
20     public class ResetListener implements ActionListener{
21         public void actionPerformed(ActionEvent e) {
22             txtName.setText("");
23             txtPwd.setText("");
24         }
25     }

 

The administrator login effect is as follows:

 

The code of the examinee's query results is as follows:

 1 private void showData() {
 2         String id = txtId.getText();
 3         String sql = "select id as Examinee number,geography as Geography,chemistry as Chemistry,IT as information technology,History as history ,Biology as biology,mathematics as mathematics,general_technique as General technology,physics as Physics,english as English,chinese as language,politics as Politics  from information_of_grade where id = '"+id+"'";
 4         DBUtil db = new DBUtil();
 5         try {
 6             db.getConnection();
 7             ResultSet rs = db.executeQuery(sql, null);
 8             ResultSetMetaData rsmd = rs.getMetaData();
 9             int colCount = rsmd.getColumnCount();
10             Vector<String> title = new Vector<String>();  //Storage title
11             for(int i = 1;i<=colCount;i++) {
12                 title.add(rsmd.getColumnLabel(i));
13             }
14             Vector<Vector<String>> data = new Vector<Vector<String>>();    //Storing tabular data
15             int rowCount = 0;
16             while(rs.next()) {
17                 rowCount++;
18                 Vector<String> rowdata = new Vector<String>();         //Store row data
19                 for(int i = 1;i<=colCount;i++) {
20                     rowdata.add(rs.getString(i));
21                 }
22                 data.add(rowdata);
23             }
24             if(rowCount == 0) {
25                 model.setDataVector(null, title);
26             } else {
27                 model.setDataVector(data,title);
28             }
29         } catch(Exception ee) {
30             System.out.println(ee.toString());
31             JOptionPane.showMessageDialog(this, "An unexpected error occurred in the system. Please check the database. System coming soon!!!","error",0);
32         } finally {
33             db.closeAll();
34         }
35         JOptionPane.showMessageDialog(null, "Query the candidate information");
36     }

 

The results of candidates' query are as follows:

 

The export code of examinee's score is as follows:

 1 public void saveFile() {
 2         JFileChooser fc = new JFileChooser();
 3         int rVal = fc.showSaveDialog(this);
 4         if(rVal == JFileChooser.APPROVE_OPTION) {
 5             String fileName = fc.getSelectedFile().getName();
 6             String path = fc.getCurrentDirectory().toString();
 7             try {
 8                 TableModel model = table.getModel(); 
 9                 FileWriter fw = new FileWriter(path + "/" + fileName);
10                 for(int i=0; i < model.getColumnCount(); i++) { 
11                     fw.write(model.getColumnName(i) + "\t"); 
12                 } 
13                 fw.write("\n"); 
14                 for(int i=0; i< model.getRowCount(); i++) { 
15                     for(int j=0; j < model.getColumnCount(); j++) { 
16                         fw.write(model.getValueAt(i,j).toString()+"\t"); 
17                     } 
18                     fw.write("\n");
19                 } 
20                 fw.close();
21             } catch(Exception e) {
22                 e.printStackTrace();
23             }
24             JOptionPane.showMessageDialog(null, "Export succeeded");
25         }
26     }

 

The export effect of candidates' scores is as follows:

 

The code for the examinee to modify the password is as follows:

 1 public class listener_of_delete implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                String id = jtId.getText();
 4                String code = new String(jpCode.getPassword());
 5                String code1 = new String(jpCode1.getPassword());
 6                DBUtil db = new DBUtil();
 7                String sql = "update information_of_students set pwd = '"+code+"' where id = '"+id+"'";
 8                if(code.equals(code1)){
 9                    try {
10                        db.getConnection();
11                        db.executeUpdate(sql,null);
12                    } catch(Exception ee) {
13                        System.out.println(ee.toString());
14                    } finally {
15                        db.closeAll();
16                    }
17                    JOptionPane.showMessageDialog(null, "Modified successfully");
18                }
19                else{
20                    JOptionPane.showMessageDialog(null, "The two passwords are different!");
21                }
22            }
23     }

 

The effect of the examinee changing the password is as follows:

 

The code of the administrator main panel is as follows:

 1 public MainFrame_Of_Administration() {
 2         super("Administration");
 3         ImageIcon qstIcon = new ImageIcon("images\\1.png");
 4         this.setIconImage(qstIcon.getImage());
 5         p = new JPanel();
 6         setBak();
 7         clipboard=getToolkit().getSystemClipboard();
 8         Container c = getContentPane();
 9         p.setOpaque(false);
10         c.add(p);
11         p.setLayout(null);
12 
13         jbInsert = new JButton("Add candidate information");
14         jbDelete = new JButton("Delete candidate information");
15         jbUpdate = new JButton("Modify candidate information");
16         jbAdministration = new JButton("Return to the login interface");
17         jbResetCode = new JButton("Reset candidate password");
18 
19         jbAdministration.addActionListener(new loginframe_of_administration());
20         jbDelete.addActionListener(new listener_of_delete());
21         jbInsert.addActionListener(new listener_of_insert());
22         jbUpdate.addActionListener(new listener_of_update());
23         jbResetCode.addActionListener(new listener_of_reset());
24 
25         jbInsert.setBounds(0,20,120,25);
26         jbDelete.setBounds(0,55,120,25);
27         jbUpdate.setBounds(0,90,120,25);
28         jbAdministration.setBounds(0,125,120,25);
29         jbResetCode.setBounds(0,165,120,25);
30 
31         p.add(jbInsert);
32         p.add(jbDelete);
33         p.add(jbUpdate);
34         p.add(jbAdministration);
35         p.add(jbResetCode);
36         this.add(p);
37         this.setLocation(200,100);
38         this.setSize(533,300);
39         this.setResizable(false);
40         this.setVisible(true);
41         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
42 
43     }

 

The effect of the administrator main panel is as follows:

 

The code for adding candidate information is as follows:

 1 public class listener_of_insert implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                DBUtil db = new DBUtil();
 4                String preparedsql = "insert into information_of_grade(id,geography,chemistry,IT,history,biology,mathematics,general_technique,physics,english,chinese,politics)"+"values(?,?,?,?,?,?,?,?,?,?,?,?)";
 5 
 6                try {
 7                    db.getConnection();
 8                    Object param[] = {jtId.getText(),jtGeo.getText(),jtChe.getText(),jtIT.getText(),jtHis.getText(),jtBio.getText(),jtMath.getText(),jtGen.getText(),jtPhy.getText(),jtEng.getText(),jtChi.getText(),jtPol.getText()};
 9                    db.executeUpdate(preparedsql, param);
10                } catch(Exception ee) {
11                    System.out.println(ee.toString());
12                } finally {
13                    db.closeAll();
14                }
15                JOptionPane.showMessageDialog(null, "Successfully added candidate information");
16         }
17     }

 

The effect of adding candidate information is as follows:

 

Delete the code of candidate information as follows:

 1 public class listener_of_delete implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                String id = jtId.getText();
 4                DBUtil db = new DBUtil();
 5                String sql = "delete from information_of_grade where id = '"+id+"'";
 6 
 7                try {
 8                    db.getConnection();
 9                    db.executeUpdate(sql,null);
10                } catch(Exception ee) {
11                    System.out.println(ee.toString());
12                } finally {
13                    db.closeAll();
14                }
15                JOptionPane.showMessageDialog(null, "Successfully deleted candidate information");
16         }
17     }

 

The effect of deleting candidate information is as follows:

 

Modify the code of candidate information as follows:

 1 public class listener_of_delete implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                String id = jtId.getText();
 4                String code = new String(jpCode.getPassword());
 5                String code1 = new String(jpCode1.getPassword());
 6                DBUtil db = new DBUtil();
 7                String sql = "update information_of_students set pwd = '"+code+"' where id = '"+id+"'";
 8                if(code.equals(code1)){
 9                    try {
10                        db.getConnection();
11                        db.executeUpdate(sql,null);
12                    } catch(Exception ee) {
13                        System.out.println(ee.toString());
14                    } finally {
15                        db.closeAll();
16                    }
17                    JOptionPane.showMessageDialog(null, "Modified successfully");
18                }
19                else{
20                    JOptionPane.showMessageDialog(null, "The two passwords are different!");
21                }
22            }
23     }

 

The effect of modifying candidate information is as follows:

 

The codes for resetting the examinee's password are as follows:

 1 public class listener_of_delete implements ActionListener{
 2            public void actionPerformed(ActionEvent e){
 3                String id = jtId.getText();
 4                DBUtil db = new DBUtil();
 5                String sql = "update information_of_students set pwd = '000000' where id = '"+id+"'";
 6                try {
 7                    db.getConnection();
 8                    db.executeUpdate(sql,null);
 9                } catch(Exception ee) {
10                    System.out.println(ee.toString());
11                } finally {
12                    db.closeAll();
13                  }
14                  JOptionPane.showMessageDialog(null, "Reset successful");
15            }
16     }

 

The effect of resetting the examinee's password is as follows:

 

 

4, Complete source code download

Download the source code of HKCEE score management system:

  • Focus on my original WeChat official account: "little hung starsky technology", reply to the student achievement examination management system, get the complete project.

 

 

5, Author Info

Author: under Nanke tree, Goal: make programming more interesting!

The original WeChat official account: "little hung starsky technology", focusing on algorithms, crawlers, web sites, game development, data analysis, Natural Language Processing, AI, etc., looking forward to your attention, let's grow together and Coding together!

Copyright notice: plagiarism and reprint are prohibited in this article. Infringement must be investigated!

 

Welcome to the code of mine, my original official account, reply to the student achievement management system, and get the complete project.

 

-  -  -  -  —  END  -  -  -  -  -- 

Welcome to scan code to pay attention to my official account.

Xiaohong XingKong Technology

       

Keywords: Java MySQL Eclipse swing

Added by icaro on Wed, 05 Jan 2022 17:02:40 +0200