[Graduation project] source code of student information management system based on java+mysql (test runs through)

Table of contents

1. Introduction

2. Main technologies

3. Basic functional requirements of the system

3.1 System structure

3.2 Analysis of database requirements

3.3 System Objectives

4. Design of database table

5. Detailed design and implementation of the system

5.1 System design and implementation

5.1.1 Realization of login interface

5.1.2 System main interface

 5.1.3 Realization of student information management

5.1.4 Class information management

5.1.5 Grade Information Management

5.1.6 Data dictionary category management

5.1.8 System related settings

6. Source code acquisition:


 Source code acquisition: source code of student information management system based on java+mysql (test runs through)

1. Introduction

The student information management system is an indispensable part of an educational unit. A fully functional, easy-to-use information management system can not only effectively reduce the workload of relevant school staff, but its content is very important to school decision makers and managers. Therefore, the student information management system should be able to provide users with sufficient information and fast query methods. However, people have been using traditional manual methods to manage file archives, statistics and query data. This management method has many shortcomings, such as: low efficiency, poor confidentiality, and a lot of waste of labor; in addition, a large number of files will be generated over time. and data, which brings many difficulties to search, update and maintenance. With the continuous improvement of science and technology, computer science is becoming more and more mature, and its powerful functions have been deeply recognized by people. It has entered various fields of human society and is playing an increasingly important role. 

    As a part of computer application, using computer to manage all kinds of school information has advantages that cannot be compared with manual management. For example: fast retrieval, convenient query, high efficiency, good reliability, large storage capacity, good confidentiality, long life long and low cost. These advantages can greatly improve the efficiency of school information management, and are also an important condition for a unit to be scientifically and formally managed and to be in line with the world.  

2. Main technologies

Technical name

effect
Java + Struts2 backend framework
Jsp front-end framework
MySQL database

3. Basic functional requirements of the system

The system involves a kind of authority of the system administrator; next, the functional structure will be described for this authority;

3.1 System structure

The main functions are:

System administrator: student information management, class information management, grade information management, system management (including data dictionary management, data dictionary category management, password modification)

System business flow chart:

 

3.2 Analysis of database requirements

According to the content involved in the above business flow chart, the tables to be designed in the database are: student table, class table, grade table, data dictionary category table, data dictionary table, management table

3.3 System Objectives

The design of this topic selection system will mainly achieve the following goals:

  1. .Humanized design: the system interface is friendly and the operation is simple;

.Realize the management of student information, class information, and grade information;

4. Design of database table

(1). Administrator Information Form

field name

type of data

length

Whether primary key

describe

UserId

Int

yes

auto numbering

Username

varchar

20

username

Password

varchar

20

password

(2). Student table

field name

type of data

length

Whether primary key

describe

studentId

varchar

40

yes

UUID

stuNo

varchar

20

student ID

stuName

varchar

20

student name

stuSex

varchar

10

student gender

stuBirthday

date

date of birth

stuRxsj

date

Admission time

stuNation

varchar

20

nationality

stuZzmm

varchar

20

political status

classId

int

11

class number

stuDesc

text

Remark

stuPic

varchar

20

student photo

  1. . Class table

field name

type of data

length

Whether primary key

describe

classId

Int

11

yes

auto numbering

className

varchar

20

class name

gradeId

Int

11

grade foreign key

classDesc

Text

class description

  1. . Grade Table

field name

type of data

length

Whether primary key

describe

gradeId

Int

11

yes

auto numbering

gradeName

Varchar

20

grade name

gradeDesc

text

grade notes

  1. . Data dictionary table

field name

type of data

length

Whether primary key

describe

id

Int

11

yes

auto numbering

ddTypeId

int

11

Data Dictionary Class

ddValue

varchar

20

data dictionary value

ddDesc

text

Remark

  1. . Data dictionary category table

field name

type of data

length

Whether primary key

describe

ddTypeId

Int

11

yes

auto numbering

ddTypeName

varchar

20

Data Dictionary Class

ddTypeDesc

text

Remark

5. Detailed design and implementation of the system

5.1 System design and implementation

5.1.1 Realization of login interface

 Renderings:

Related instructions:

The user enters the system login interface, the user enters the user name, password, and verification code, and enters the main interface of the system if the input is correct;

Key code implementation:

public User login(Connection con,User user)throws Exception{
		User resultUser=null;
		String sql="select * from t_user where userName=? and password=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, user.getUserName());
		pstmt.setString(2, user.getPassword());
		ResultSet rs=pstmt.executeQuery();
		if(rs.next()){
			resultUser=new User();
			resultUser.setUserId(rs.getInt("userId"));
			resultUser.setUserName(rs.getString("userName"));
			resultUser.setPassword(rs.getString("password"));
		}
		return resultUser;
	}

5.1.2 System main interface

Related instructions:

 The user enters the correct user name, password and verification code, clicks to log in, and the background verification is successful, then enters the main interface of the system, which mainly includes four functions, student information management, class information management, grade information management, and system management;

Key code implementation:

Public page head.jsp

<div class="row-fluid">
	<div class="span12">
		<div class="head">
			<div class="headLeft">
				<img src="${pageContext.request.contextPath}/images/logo.png"/>
			</div>
			<div class="headRight">
				欢迎管理员:<font color="red">${currentUser.userName }</font>&nbsp;&nbsp;&nbsp;<font id="today" class="currentDateTime"></font>
			</div>
		</div>
	</div>
</div>

Public page menu.jsp

<div class="row-fluid">
	<div class="span12">
		<div class="navbar">
		  <div class="navbar-inner">
		    <a class="brand" href="main.jsp">首页</a>
		    <ul class="nav">
		    	<li class="dropdown">
                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">学生信息管理 <b class="caret"></b></a>
                       <ul class="dropdown-menu">
                         <li><a href="student!preSave">学生信息添加</a></li>
                         <li><a href="student!list">学生信息维护</a></li>
                       </ul>
                   </li>
		      	<li class="dropdown">
                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">班级信息管理 <b class="caret"></b></a>
                       <ul class="dropdown-menu">
                         <li><a href="class!preSave">班级信息添加</a></li>
                         <li><a href="class!list">班级信息维护</a></li>
                       </ul>
                   </li>
                   <li class="dropdown">
                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">年级信息管理 <b class="caret"></b></a>
                       <ul class="dropdown-menu">
                         <li><a href="grade!preSave">年级信息添加</a></li>
                         <li><a href="grade!list">年级信息维护</a></li>
                       </ul>
                   </li>
		        <li class="dropdown">
                       <a href="#" class="dropdown-toggle" data-toggle="dropdown">系统管理 <b class="caret"></b></a>
                       <ul class="dropdown-menu">
                         <li><a href="dataDic!list">数据字典维护</a></li>
                         <li><a href="dataDicType!list">数据字典类别维护</a></li>
                         <li><a href="user!preSave">修改密码</a></li>
                         <li class="divider"></li>
                         <li><a href="javascript:logOut()">退出系统</a></li>
                       </ul>
                   </li>
		    </ul>

public page foot.jsp

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<div class="row-fluid" style="margin-top: 30px;">
	<div class="span12">
		<div class="foot">Copyright © 2013-2014 XXX 版权所有</div>
	</div>
</div>

 5.1.3 Realization of student information management

 Student information to add:

 Student information modification:

 To view student information:

 Delete student information:

Related instructions:

 The student information maintenance module includes the above functions: student information display, student information query, student information addition, modification, deletion;

Key code implementation:

  Student Information Inquiry:

public List<Student> studentList(Connection con,Student s_student,PageBean pageBean)throws Exception{
		List<Student> studentList=new ArrayList<Student>();
		...此处省略sql拼接代码
		if(pageBean!=null){
			sb.append(" limit "+pageBean.getStart()+","+pageBean.getPageSize());
		}
		System.out.println(sb.toString());
		PreparedStatement pstmt=con.prepareStatement(sb.toString());
		ResultSet rs=pstmt.executeQuery();
		while(rs.next()){
			Student student=new Student();
			student.setStudentId(rs.getString("studentId"));
			student.setStuNo(rs.getString("stuNo"));
			student.setStuName(rs.getString("stuName"));
			student.setStuSex(rs.getString("stuSex"));
			student.setStuBirthday(DateUtil.formatString(rs.getString("stuBirthday"),"yyyy-MM-dd"));
			student.setStuRxsj(DateUtil.formatString(rs.getString("stuRxsj"),"yyyy-MM-dd"));
			student.setStuNation(rs.getString("stuNation"));
			student.setStuZzmm(rs.getString("stuZzmm"));
			student.setClassId(rs.getInt("classId"));
			student.setClassName(rs.getString("className"));
			student.setStuDesc(rs.getString("stuDesc"));
			student.setStuPic(rs.getString("stuPic"));
			student.setGradeId(rs.getInt("gradeId"));
			student.setGradeName(rs.getString("gradeName"));
			studentList.add(student);
		}
		return studentList;
	}

Student information to add:

public int studentAdd(Connection con,Student student)throws Exception{
		String sql="insert into t_student values(?,?,?,?,?,?,?,?,?,?,?)";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, UUIDUtil.getUUID());
		pstmt.setString(2, student.getStuNo());
		pstmt.setString(3, student.getStuName());
		pstmt.setString(4, student.getStuSex());
		pstmt.setString(5, DateUtil.formatDate(student.getStuBirthday(), "yyyy-MM-dd"));
		pstmt.setString(6, DateUtil.formatDate(student.getStuRxsj(), "yyyy-MM-dd"));
		pstmt.setString(7, student.getStuNation());
		pstmt.setString(8, student.getStuZzmm());
		pstmt.setInt(9, student.getClassId());
		pstmt.setString(10, student.getStuDesc());
		pstmt.setString(11, student.getStuPic());
		return pstmt.executeUpdate();
	}

Student information modification:

public int studentUpdate(Connection con,Student student)throws Exception{
		String sql="update t_student set stuNo=?,stuName=?,stuSex=?,stuBirthday=?,stuRxsj=?,stuNation=?,stuZzmm=?,classId=?,stuDesc=?,stuPic=? where studentId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, student.getStuNo());
		pstmt.setString(2, student.getStuName());
		pstmt.setString(3, student.getStuSex());
		pstmt.setString(4, DateUtil.formatDate(student.getStuBirthday(), "yyyy-MM-dd"));
		pstmt.setString(5, DateUtil.formatDate(student.getStuRxsj(), "yyyy-MM-dd"));
		pstmt.setString(6, student.getStuNation());
		pstmt.setString(7, student.getStuZzmm());
		pstmt.setInt(8, student.getClassId());
		pstmt.setString(9, student.getStuDesc());
		pstmt.setString(10, student.getStuPic());
		pstmt.setString(11, student.getStudentId());
		return pstmt.executeUpdate();
	}

Student Information Deletion:

public int studentDelete(Connection con,String studentId)throws Exception{
		String sql="delete from t_student where studentId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, studentId);
		return pstmt.executeUpdate();
	}

Student information view:

public Student getStudentById(Connection con,String studentId)throws Exception{
		String sql="select * from t_student t1,t_class t2,t_grade t3 where t1.classId=t2.classId and t2.gradeId=t3.gradeId and t1.studentId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, studentId);
		ResultSet rs=pstmt.executeQuery();
		Student student=null;
		while(rs.next()){
			student=new Student();
			student.setStudentId(rs.getString("studentId"));
			student.setStuNo(rs.getString("stuNo"));
			student.setStuName(rs.getString("stuName"));
			student.setStuSex(rs.getString("stuSex"));
			student.setStuBirthday(DateUtil.formatString(rs.getString("stuBirthday"),"yyyy-MM-dd"));
			student.setStuRxsj(DateUtil.formatString(rs.getString("stuRxsj"),"yyyy-MM-dd"));
			student.setStuNation(rs.getString("stuNation"));
			student.setStuZzmm(rs.getString("stuZzmm"));
			student.setClassId(rs.getInt("classId"));
			student.setClassName(rs.getString("className"));
			student.setStuDesc(rs.getString("stuDesc"));
			student.setStuPic(rs.getString("stuPic"));
			student.setGradeId(rs.getInt("gradeId"));
			student.setGradeName(rs.getString("gradeName"));
		}
		return student;
	}

5.1.4 Class information management

Renderings:

 Class information query:

 Class information added:

 Modification of class information:

 Class information deletion:

Related instructions:

 The class information management module includes the following functions: class information query, class information addition, modification, deletion;

Key code implementation:

 Class information query:

public List<Class> classList(Connection con,Class s_class)throws Exception{
		List<Class> classList=new ArrayList<Class>();
		StringBuffer sb=new StringBuffer("select * from t_class t1,t_grade t2 where t1.gradeId=t2.gradeId");
		if(s_class!=null && s_class.getGradeId()!=-1){
			sb.append(" and t1.gradeId="+s_class.getGradeId());
		}
		PreparedStatement pstmt=con.prepareStatement(sb.toString());
		ResultSet rs=pstmt.executeQuery();
		while(rs.next()){
			Class c=new Class();
			c.setClassId(rs.getInt("classId"));
			c.setClassName(rs.getString("className"));
			c.setGradeId(rs.getInt("gradeId"));
			c.setGradeName(rs.getString("gradeName"));
			c.setClassDesc(rs.getString("classDesc"));
			classList.add(c);
		}
		return classList;
	}

Class information added:

public int classAdd(Connection con,Class c)throws Exception{
		String sql="insert into t_class values(null,?,?,?)";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, c.getClassName());
		pstmt.setInt(2, c.getGradeId());
		pstmt.setString(3, c.getClassDesc());
		return pstmt.executeUpdate();
	}

Modification of class information:

public int classUpdate(Connection con,Class c)throws Exception{
		String sql="update t_class set className=?,gradeId=?,classDesc=? where classId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, c.getClassName());
		pstmt.setInt(2, c.getGradeId());
		pstmt.setString(3, c.getClassDesc());
		pstmt.setInt(4, c.getClassId());
		return pstmt.executeUpdate();
	}

Class information deletion:

public int classDelete(Connection con,String Id)throws Exception{
		String sql="delete from t_class where classId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1,Id);
		return pstmt.executeUpdate();
	}

5.1.5 Grade Information Management

Renderings:

Grade Information Inquiry:

Grade information added: 

 Grade information modification:

Grade information deletion:

Related instructions:

 The grade information management module includes the following functions: grade information query, grade information addition, modification, deletion;

Key code implementation:

 Grade Information Inquiry:

public List<Grade> gradeList(Connection con)throws Exception{
		List<Grade> gradeList=new ArrayList<Grade>();
		String sql="select * from t_grade";
		PreparedStatement pstmt=con.prepareStatement(sql);
		ResultSet rs=pstmt.executeQuery();
		while(rs.next()){
			Grade grade=new Grade();
			grade.setGradeId(rs.getInt("gradeId"));
			grade.setGradeName(rs.getString("gradeName"));
			grade.setGradeDesc(rs.getString("gradeDesc"));
			gradeList.add(grade);
		}
		return gradeList;
	}

Grade information added:

public int gradeAdd(Connection con,Grade grade)throws Exception{
		String sql="insert into t_grade values(null,?,?)";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, grade.getGradeName());
		pstmt.setString(2, grade.getGradeDesc());
		return pstmt.executeUpdate();
	}

Grade information modification:

public int gradeUpdate(Connection con,Grade grade)throws Exception{
		String sql="update t_grade set gradeName=?,gradeDesc=? where gradeId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, grade.getGradeName());
		pstmt.setString(2, grade.getGradeDesc());
		pstmt.setInt(3, grade.getGradeId());
		return pstmt.executeUpdate();
	}

Grade Information Deletion:

public int gradeDelete(Connection con,String gradeId)throws Exception{
		String sql="delete from t_grade where gradeId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1,gradeId);
		return pstmt.executeUpdate();
	}

5.1.6 Data dictionary category management

 Add a data dictionary class:

Related instructions:

 The data dictionary category information management module includes the following functions: data dictionary category query, data dictionary category addition, modification, deletion;

Key code implementation:

 Data dictionary category information query:

public List<DataDicType> dataDicTypeList(Connection con)throws Exception{
		List<DataDicType> dataDicTypeList=new ArrayList<DataDicType>();
		String sql="select * from t_dataDicType";
		PreparedStatement pstmt=con.prepareStatement(sql);
		ResultSet rs=pstmt.executeQuery();
		while(rs.next()){
			DataDicType dataDicType=new DataDicType();
			dataDicType.setDdTypeId(rs.getInt("ddTypeId"));
			dataDicType.setDdTypeName(rs.getString("ddTypeName"));
			dataDicType.setDdTypeDesc(rs.getString("ddTypeDesc"));
			dataDicTypeList.add(dataDicType);
		}
		return dataDicTypeList;
	}

Data dictionary category information added:

public int dataDicTypeAdd(Connection con,DataDicType dataDicType)throws Exception{
		String sql="insert into t_dataDicType values(null,?,?)";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, dataDicType.getDdTypeName());
		pstmt.setString(2, dataDicType.getDdTypeDesc());
		return pstmt.executeUpdate();
	}

5.1.8 System related settings

Function Description:

 The user enters the original password, new password, and confirms the new password, all of which are required, and the original password must be correct, and the new password and the confirmed new password must be consistent, otherwise an error message will be prompted;

 key code:

public int modifyPassword(Connection con,User user)throws Exception{
		String sql="update t_user set password=? where userId=?";
		PreparedStatement pstmt=con.prepareStatement(sql);
		pstmt.setString(1, user.getPassword());
		pstmt.setInt(2, user.getUserId());
		return pstmt.executeUpdate();
	}

6. Source code acquisition

Source code of student information management system based on java+mysql (test runs through)

Guess you like

Origin blog.csdn.net/tyxjolin/article/details/130178567