java学生信息管理系统

编程入门 行业动态 更新时间:2024-10-09 06:22:06

java学生<a href=https://www.elefans.com/category/jswz/34/1769682.html style=信息管理系统"/>

java学生信息管理系统

一、面向人群

学校的学生信息管理人员以及老师和学生

二、总体功能描述

本系统利用Java Web技术实现了学生信息管理系统,具有简单的学生信息管理功能。

实现了以下功能模块:

院系信息管理模块,学生信息管理模块,课程信息管理模块,成绩管理模块

并能根据登入用户的权限自动展示相关操作。

三、运行环境

硬件环境:Windows 7 及以上,处理器:Intel Pentium及以上,内存:2G以上

浏览器:IE9 以上及Chrome,FireFox,Safari等现代浏览器

四、基本处理流程

1)用户登录流程图

2)子模块操作处理流程图

3)模块结构-系统结构图

五、算法描述

  1. 用户在前台操作,向后台发送带参数的GET请求

  1. AdminDao.java捕捉到请求,根据类型分发到不同处理方法中

  1. 处理方法中实例化XXXDao对象并调用DBUtils.java提供的方法连接和操作数据库

  1. 用ajax向前台user.jsp或者admin.jsp发送操作后的数据

六、数据库设计-概念结构设计

七、操作界面截图

八、登录注册模块

1public class LoginServlet extends HttpServlet {
2    private static final long serialVersionUID = 1L;
3    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
4        request.setCharacterEncoding("utf-8");
5        String username = request.getParameter("username");
6        String password = request.getParameter("password");
7        String level = null;
8        //实例化UserDao对象
9        UserDao userDao = new UserDao();
10        User user = userDao.login(username, password);
11        //判断是否登录成功
12        if(user != null){//成功
13            level = user.getLevel();
14            if(level.equals("用户")){
15    request.getSession().setAttribute("user", user);//将用户对象放到session中
16                //转发到user.jsp中
17                request.getRequestDispatcher("user.jsp").forward(request, response);
18            }
19            else{
20            request.getSession().setAttribute("admin", user);//将管理员对象放到session中
21                //转发到admin.jsp中
22                request.getRequestDispatcher("admin.jsp").forward(request, response);
23            }    
24        }else {//失败
25            request.setAttribute("info"," 错误:用户名或密码错误!");
26            request.getRequestDispatcher("message.jsp").forward(request, response);
27        }
28    }
}

九、增删改查模块

1public class CourseDao {
2    // 获取所有课程的信息,用ArrayList返回
3    public ArrayList<Course> query_all_course() {
4        Connection conn = DBUtils.getConnection();
5        String sql = "select * from course order by cno;";
6        ArrayList<Course> results = new ArrayList<Course>();
7        try {
8            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
9            ResultSet rs = ps.executeQuery();
10            while (rs.next()) {
11                Course temp = new Course();
12                temp.setCno(rs.getString("Cno"));
13                temp.setCname(rs.getString("Cname"));
14                temp.setCteacher(rs.getString("Cteacher"));
15                temp.setCcredit(rs.getInt("Ccredit"));
16                results.add(temp);
17            }
18            // 关闭资源
19            rs.close();
20            ps.close();
21        } catch (SQLException e) {
22            e.printStackTrace();
23        } finally {
24            DBUtils.closeConnection(conn);
25        }
26        return results;
27    }
28    // 插入课程信息,返回一个int值表示状态,1:成功,0失败
29    public int insert_course(String Cno, String Cname, String Cteacher, double Ccredit) {
30        Connection conn = DBUtils.getConnection();
31        String sql = "insert into course values(?,?,?,?);";
32        int flag = 0;
33        try {
34            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
35            ps.setString(1, Cno);
36            ps.setString(2, Cname);
37            ps.setString(3, Cteacher);
38            ps.setDouble(4, Ccredit);
39            flag = ps.executeUpdate();
40            ps.close();
41        } catch (SQLException e) {
42            e.printStackTrace();
43        } finally {
44            DBUtils.closeConnection(conn);
45        }
46        return flag;
47    }
48    // 删除课程信息,返回一个int值表示状态,1:成功,0失败
49    public int delete_course(String Cno) {
50        Connection conn = DBUtils.getConnection();
51        String sql = "delete from course where Cno = ?;";
52        int flag = 0;
53        try {
54            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
55            ps.setString(1, Cno);
56            flag = ps.executeUpdate();
57            ps.close();
58        } catch (SQLException e) {
59            e.printStackTrace();
60        } finally {
61            DBUtils.closeConnection(conn);
62        }
63        return flag;
64    }
65    //修改课程信息,返回一个int值表示状态,1:成功,0失败
66    public int alter_course(String cno,String after_cno,String after_cname,String after_cteacher,double after_ccredit) {
67        Connection conn = DBUtils.getConnection();
68        String sql = "update course set cno = ?,cname = ?,cteacher = ?,ccredit = ? where cno = ?;";
69        int flag = 0;
70        try {
71            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
72            ps.setString(1, after_cno);
73            ps.setString(2, after_cname);
74            ps.setString(3, after_cteacher);
75            ps.setDouble(4, after_ccredit);
76            ps.setString(5, cno);
77            flag = ps.executeUpdate();
78            ps.close();
79        } catch (SQLException e) {
80            e.printStackTrace();
81        }finally {
82            DBUtils.closeConnection(conn);
83        }
84        return flag;
85    }
86    // 查询课程平均分信息,返回一个ArrayLst集合
87    public ArrayList<Course_avg> course_avg() {
88        Connection conn = DBUtils.getConnection();
89        String sql = "select sco cno,cname,avg(grade) avg from course,sc where courseo = sco group by cno order by cno;";
90        ResultSet result = null;
91        ArrayList<Course_avg> course_avg = new ArrayList<Course_avg>();
92        try {
93            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
94            result = ps.executeQuery();
95            while(result.next()){
96                Course_avg temp = new Course_avg();
97                temp.setCno(result.getString("Cno"));
98                temp.setCname(result.getString("Cname"));
99                temp.setAvg(result.getDouble("avg"));
100                course_avg.add(temp);
101            }
102            ps.close();
103            result.close();
104        } catch (SQLException e) {
105            e.printStackTrace();
106        } finally {
107            DBUtils.closeConnection(conn);
108        }
109        return course_avg;
110    }
111    //查询课程不及格率,返回一个ArrayList集合
112    public ArrayList<Course_fail_rate> fail_rate(){
113        Connection conn = DBUtils.getConnection();
114        String sql = "select cno,(select cname from course where cno = xo) cname,cast(100.0*(select count(sno) from sc where grade < 60 and cno = xo)/(select count(sno) from sc where cno = xo) as decimal(18,2)) rate from sc x group by cno order by cno;";
115        ArrayList<Course_fail_rate> fail_rate = new ArrayList<Course_fail_rate>();
116        try {
117            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
118            ResultSet rs = ps.executeQuery();
119            while(rs.next()){
120                Course_fail_rate temp = new Course_fail_rate();
121                temp.setCno(rs.getString("cno"));
122                temp.setCname(rs.getString("cname"));
123                temp.setFail_rate(rs.getDouble("rate"));
124                fail_rate.add(temp);
125            }
126            rs.close();
127            ps.close();
128        } catch (SQLException e) {
129            e.printStackTrace();
130        } finally {
131            DBUtils.closeConnection(conn);
132        }
133        return fail_rate;
134    }
135    //查询课程排名情况,返回一个ArrayList集合
136    public ArrayList<Course_ranking> course_ranking(String cno){
137        Connection conn = DBUtils.getConnection();
138        String sql = "select student.Sno Sno,Dname,Clname,Sname,Ssex,Sage,Grade from department,class,student,sc where student.sno = sc.sno and class.Clno = student.Clno and department.Dno = class.Dno and cno = '"+cno+"' order by grade desc;";
139        ArrayList<Course_ranking> course_ranking = new ArrayList<Course_ranking>();
140        try {
141            PreparedStatement ps = (PreparedStatement) conn.prepareStatement(sql);
142            ResultSet rs = ps.executeQuery();
143            while(rs.next()){
144                Course_ranking temp = new Course_ranking();
145                temp.setSno(rs.getString("Sno"));
146                temp.setDname(rs.getString("Dname"));
147                temp.setClname(rs.getString("Clname"));
148                temp.setSname(rs.getString("Sname"));
149                temp.setSsex(rs.getString("Ssex"));
150                temp.setSage(rs.getInt("Sage"));
151                temp.setGrade(rs.getDouble("Grade"));
152                course_ranking.add(temp);
153            }
154            rs.close();
155            ps.close();
156        } catch (SQLException e) {
157            e.printStackTrace();
158        } finally {
159            DBUtils.closeConnection(conn);
160        }
161        return course_ranking;
162    }
}

十、项目链接

更多推荐

java学生信息管理系统

本文发布于:2024-02-13 06:27:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1757725.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:信息管理系统   学生   java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!