IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> IDEA+Java+Servlet+JSP+Bootstrap+Mysql实现Web学生成绩管理系统 -> 正文阅读

[Java知识库]IDEA+Java+Servlet+JSP+Bootstrap+Mysql实现Web学生成绩管理系统

目录

?

一、系统介绍

1.开发环境

2.技术选型

3.系统功能

4.数据库

5.工程截图

二、系统展示

1.注册页面

2.登录页面

3.学生-主页面

4.学生-个人信息-查询登录密码

5.学生-个人信息-查看个人信息

6.学生-个人信息-修改个人信息

7.学生-成绩管理-成绩信息查看

8.教师-主页面

9.教师-个人信息-查询登录密码

10.教师-个人信息-查看个人信息

11.教师-个人信息-修改个人信息

12.教师-课程管理-课程信息查看

13.教师-课程管理-添加课程信息

14.教师-成绩管理-成绩信息查看

15.教师-成绩管理-添加学生成绩

16.教师-学生管理-查询学生信息

17.管理员-主页面

18.管理员-个人信息

19.管理员-课程管理-课程信息查看

20.管理员-课程管理-添加课程信息

21.管理员-成绩管理-成绩信息查看

22.管理员-成绩管理-添加学生成绩

23.管理员-成绩管理-学生总成绩

24.管理员-教师管理-查询教师信息

25.管理员-教师管理-添加教师信息

26.管理员-学生管理-查询学生信息

27.管理员-学生管理-添加学生信息

28.管理员-查询所有账号

三、部分代码

CourseDaoImpl

ScoreDaoImpl

StudentDaoImpl

TeacherDaoImpl

UserDaoImpl

DBCon

register.jsp

login.jsp

selectScore.jsp

四、其他

1.其他系统实现

1.JavaWeb系统系列实现

2.JavaSwing系统系列实现

2.获取源码

3.运行项目

4.备注

5.支持博主


一、系统介绍

1.开发环境

开发工具:IDEA2018.2

JDK版本:jdk1.8

Mysql版本:8.0.13

2.技术选型

1.后端:使用Java+Servlet进行开发,使用过滤器来验证用户是否登录,使用MVC进行分层。

2.数据库:使用JDBC连接数据库,使用getResourceAsStream获取数据库配置文件的信息。

3.前端:使用Bootstrap作为前端框架来开发,使用到jstl来遍历数据。jsp来展示页面。

3.系统功能

1.学生

1.登录系统

2.个人信息

查询登录密码,查看个人信息,修改个人信息。

3.成绩管理

成绩信息查看

2.教师

1.登录系统

2.个人信息

查询登录密码,查看个人信息,修改个人信息。

3.课程管理

课程信息查看,添加课程信息。

4.成绩管理

成绩信息查看,添加学生成绩。

5.学生管理

查询学生信息,修改学生信息,删除学生信息。

3.管理员

1.登录系统

2.个人信息

3.课程管理

课程信息查看,修改课程信息,删除课程信息,添加课程信息。

4.成绩管理

成绩信息查看,修改学生成绩,删除学生成绩,添加学生成绩,学生总成绩。

5.教师管理

查询教师信息,修改教师信息,删除教师信息,添加教师信息。

6.学生管理

查询学生信息,修改学生信息,删除学生信息,添加学生信息。

7.查询所有账号

查询所有信息,修改信息。

4.数据库

/*
 Navicat Premium Data Transfer

 Source Server         : Mysql
 Source Server Type    : MySQL
 Source Server Version : 80013
 Source Host           : localhost:3306
 Source Schema         : jsp_servlet_score

 Target Server Type    : MySQL
 Target Server Version : 80013
 File Encoding         : 65001

 Date: 03/07/2021 16:46:10
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for course
-- ----------------------------
DROP TABLE IF EXISTS `course`;
CREATE TABLE `course`  (
  `course_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '课程编号',
  `course_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '课程名',
  `course_credit` int(11) NOT NULL COMMENT '学分',
  `course_hours` int(11) NOT NULL COMMENT '学时',
  `course_teacher` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '任课教师',
  `coursedate` date NOT NULL COMMENT '开课时间',
  PRIMARY KEY (`course_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of course
-- ----------------------------
INSERT INTO `course` VALUES (1, 'C++程序设计教程', 5, 60, '汪维清', '2017-03-02');
INSERT INTO `course` VALUES (2, 'java入门基础', 3, 60, '肖兴江', '2017-02-09');
INSERT INTO `course` VALUES (3, '计算机组成原理', 3, 60, '胡继宽', '2017-02-09');
INSERT INTO `course` VALUES (4, '信息检索', 2, 60, '郑蔚', '2017-02-09');
INSERT INTO `course` VALUES (5, '操作系统原理', 4, 60, '丁华峰', '2018-03-15');
INSERT INTO `course` VALUES (6, '管理信息系统', 4, 60, '杜治国', '2019-02-11');

-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role`  (
  `role_id` int(11) NOT NULL COMMENT '角色编号',
  `role_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色名称',
  `role_info` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '角色信息',
  PRIMARY KEY (`role_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES (0, '学生', '学生查看成绩');
INSERT INTO `role` VALUES (1, '教师', '教师操作');
INSERT INTO `role` VALUES (2, '管理员', '管理员操作');

-- ----------------------------
-- Table structure for score
-- ----------------------------
DROP TABLE IF EXISTS `score`;
CREATE TABLE `score`  (
  `score_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '成绩编号',
  `stu_num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '学号',
  `stu_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名',
  `stu_class` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '班级',
  `course_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '科目',
  `score_grade` double(11, 2) NOT NULL COMMENT '成绩',
  `major` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '专业',
  PRIMARY KEY (`score_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 112 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of score
-- ----------------------------
INSERT INTO `score` VALUES (1, '170340', '张三', '计科1701', 'java入门基础', 96.50, '计算机');
INSERT INTO `score` VALUES (2, '170340', '张三', '计科1701', 'C++程序设计教程', 85.00, '计算机');
INSERT INTO `score` VALUES (3, '160341', '王五', '信管1601', 'java入门基础', 62.60, '信息管理与信息系统');
INSERT INTO `score` VALUES (4, '160341', '王五', '信管1601', 'C++程序设计教程', 85.00, '信息管理与信息系统');
INSERT INTO `score` VALUES (5, '170340', '张三', '计科1701', '计算机组成原理', 69.00, '计算机');
INSERT INTO `score` VALUES (6, '170340', '张三', '计科1701', '信息检索', 95.00, '计算机');
INSERT INTO `score` VALUES (7, '170340', '张三', '计科1701', '操作系统原理', 89.00, '计算机');
INSERT INTO `score` VALUES (8, '160341', '王五', '计科1701', 'C++程序设计教程', 95.00, '计算机');
INSERT INTO `score` VALUES (9, '160341', '王五', '信管1601', 'java入门基础', 92.00, '信息管理与信息系统');
INSERT INTO `score` VALUES (10, '160341', '王五', '信管1601', '计算机组成原理', 83.00, '信息管理与信息系统');
INSERT INTO `score` VALUES (11, '170339', '李四', '计科1701', 'java入门基础', 78.20, '计算机');
INSERT INTO `score` VALUES (12, '170339', '李四', '计科1701', '信息检索', 98.00, '计算机');
INSERT INTO `score` VALUES (13, '170339', '李四', '计科1701', '计算机组成原理', 76.00, '计算机');
INSERT INTO `score` VALUES (14, '170339', '李四', '计科1701', '操作系统原理', 69.80, '计算机');
INSERT INTO `score` VALUES (15, '170339', '李四', '计科1701', 'C++程序设计教程', 89.00, '计算机');
INSERT INTO `score` VALUES (16, '170343', '陈留', '计科1701', 'java入门基础', 80.50, '计算机');

-- ----------------------------
-- Table structure for student
-- ----------------------------
DROP TABLE IF EXISTS `student`;
CREATE TABLE `student`  (
  `stu_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
  `stu_num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '账号',
  `stu_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名',
  `stu_sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '性别',
  `stu_age` int(11) NOT NULL COMMENT '年龄',
  `stu_class` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '班级',
  `major` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '专业',
  `department` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '院系',
  PRIMARY KEY (`stu_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 35 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of student
-- ----------------------------
INSERT INTO `student` VALUES (1, '160341', '王五', '女', 21, '信管1601', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (2, '170340', '张三', '男', 20, '计科1701', '计算机', '商贸学院');
INSERT INTO `student` VALUES (3, '170339', '李四', '男', 20, '计科1701', '计算机', '商贸学院');
INSERT INTO `student` VALUES (4, '170343', '陈留', '男', 40, '计科1701', '计算机', '商贸学院');
INSERT INTO `student` VALUES (5, '160342', '盛祎琛', '女', 19, '信管1602', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (6, '160343', '闫玉平', '女', 20, '信管1601', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (7, '160344', '陈淑婷', '女', 20, '信管1601', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (8, '160345', '周梦琪', '女', 20, '信管1601', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (9, '160346', '曾智', '女', 20, '信管1601', '信息管理与信息系统', '商贸学院');
INSERT INTO `student` VALUES (11, '160348', '多罗罗', '男', 25, '信管1601', '信息管理与信息系统', '商贸学院');

-- ----------------------------
-- Table structure for teacher
-- ----------------------------
DROP TABLE IF EXISTS `teacher`;
CREATE TABLE `teacher`  (
  `tea_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
  `tea_num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '工号',
  `tea_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名',
  `tea_sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '性别',
  `tea_age` int(11) NOT NULL COMMENT '年龄',
  `tea_course` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '所任课程',
  `major` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '专业',
  `department` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '院系',
  PRIMARY KEY (`tea_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of teacher
-- ----------------------------
INSERT INTO `teacher` VALUES (1, '1123', '肖兴江', '男', 30, 'java入门基础', '计算机', '商贸学院');
INSERT INTO `teacher` VALUES (2, '1124', '汪维清', '男', 25, 'C++程序设计教程', '计算机', '商贸学院');
INSERT INTO `teacher` VALUES (3, '1125', '胡继宽', '男', 32, '计算机组成原理', '信息管理与信息系统', '商贸学院');
INSERT INTO `teacher` VALUES (4, '1126', '郑蔚', '女', 34, '信息检索', '信息管理与信息系统', '商贸学院');
INSERT INTO `teacher` VALUES (5, '1127', '丁华峰', '男', 40, '操作系统原理', '计算机', '商贸学院');
INSERT INTO `teacher` VALUES (6, '1128', '杜治国', '男', 35, '管理信息系统', '信息管理与信息系统', '商贸学院');

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户编号',
  `user_num` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户账号',
  `user_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
  `password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
  `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户电话',
  `role_id` int(11) NOT NULL COMMENT '角色编号(外键)',
  PRIMARY KEY (`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 43 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, '160341', '王五', '123456', '14829726746', 0);
INSERT INTO `user` VALUES (2, '170340', '张三', '123456', '15869483651', 0);
INSERT INTO `user` VALUES (3, '170339', '李四', '123456', '13589462584', 0);
INSERT INTO `user` VALUES (6, '1123', '肖兴江', '123456', '17418953551', 1);
INSERT INTO `user` VALUES (7, '1124', '汪维清', '123456', '15897683584', 1);
INSERT INTO `user` VALUES (9, '1125', '胡继宽', '123456', '12378945862', 1);
INSERT INTO `user` VALUES (10, '1126', '郑蔚', '123456', '13589462584', 1);
INSERT INTO `user` VALUES (11, '1001', '管理员', 'admin', '18179586325', 2);
INSERT INTO `user` VALUES (12, '1127', '丁华峰', '123456', '16123598785', 1);
INSERT INTO `user` VALUES (13, '1128', '杜治国', '123456', '13158794456', 1);
INSERT INTO `user` VALUES (14, '160344', '陈淑婷', '123456', '14829726746', 0);
INSERT INTO `user` VALUES (15, '160345', '周梦琪', '123456', '14829726746', 0);

-- ----------------------------
-- Triggers structure for table student
-- ----------------------------
DROP TRIGGER IF EXISTS `stuLogin`;
delimiter ;;
CREATE TRIGGER `stuLogin` AFTER DELETE ON `student` FOR EACH ROW begin 
delete from user where user_num=old.stu_num;
end
;;
delimiter ;

-- ----------------------------
-- Triggers structure for table teacher
-- ----------------------------
DROP TRIGGER IF EXISTS `teaLogin`;
delimiter ;;
CREATE TRIGGER `teaLogin` AFTER DELETE ON `teacher` FOR EACH ROW begin
delete from user where user_num=old.tea_num;
end
;;
delimiter ;

SET FOREIGN_KEY_CHECKS = 1;

5.工程截图

二、系统展示

1.注册页面

2.登录页面

3.学生-主页面

4.学生-个人信息-查询登录密码

5.学生-个人信息-查看个人信息

6.学生-个人信息-修改个人信息

7.学生-成绩管理-成绩信息查看

8.教师-主页面

9.教师-个人信息-查询登录密码

10.教师-个人信息-查看个人信息

11.教师-个人信息-修改个人信息

12.教师-课程管理-课程信息查看

13.教师-课程管理-添加课程信息

14.教师-成绩管理-成绩信息查看

15.教师-成绩管理-添加学生成绩

16.教师-学生管理-查询学生信息

17.管理员-主页面

18.管理员-个人信息

19.管理员-课程管理-课程信息查看

20.管理员-课程管理-添加课程信息

21.管理员-成绩管理-成绩信息查看

22.管理员-成绩管理-添加学生成绩

23.管理员-成绩管理-学生总成绩

24.管理员-教师管理-查询教师信息

25.管理员-教师管理-添加教师信息

26.管理员-学生管理-查询学生信息

27.管理员-学生管理-添加学生信息

28.管理员-查询所有账号

三、部分代码

CourseDaoImpl

package dao.Impl;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;

import java.util.ArrayList;
import java.util.List;

import model.Course;
import model.PageBean;
import dao.CourseDao;
import db.DBCon;

public class CourseDaoImpl implements CourseDao {

	private DBCon dbCon = new DBCon();
	private Course course;
	private PageBean pageBean;

	public int addCos(Course course, String courseDate) {
		System.out.println(courseDate);
		// Date courseDate=(Date) course.getCourseDate();
		// DateFormat
		// data=DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.MEDIUM);
		String sql = "insert into course(course_name,course_credit,course_hours,course_teacher,coursedate) values('"
				+ course.getCourseName()
				+ "',"
				+ course.getCourseCredit()
				+ ","
				+ course.getCourseHours()
				+ ",'"
				+ course.getCourseTeacher() + "',DATE('" + courseDate + "'))";
		int rs = dbCon.query(sql);
		return rs;
	}

	public int deleteCos(int courseID) {
		String sql = "delete from course where course_id=" + courseID;
		int rs = dbCon.query(sql);
		return rs;
	}

	public int editCos(Course course, String courseDate) {
		String sql = "update course set course_name='" + course.getCourseName()
				+ "',course_credit=" + course.getCourseCredit()
				+ ",course_hours=" + course.getCourseHours()
				+ ",course_teacher='" + course.getCourseTeacher()
				+ "',coursedate=DATE('" + courseDate + "') where course_id="
				+ course.getCourseID();
		int rs = dbCon.query(sql);
		return rs;
	}

	public List findAll() {
		List<Course> list = new ArrayList<Course>();
		String sql = "select * from course";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int courseID = rs.getInt("course_id");
				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				Date courseDate = rs.getDate("coursedate");
				course = new Course(courseID, courseName, courseCredit,
						courseHours, courseTea, courseDate);
				list.add(course);
			}

		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public List findOne(int courseID) {
		List<Course> list = new ArrayList<Course>();
		String sql = "select * from course where course_id=" + courseID;
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int courseid = rs.getInt("course_id");
				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				Date courseDate = rs.getDate("coursedate");
				course = new Course(courseid, courseName, courseCredit,
						courseHours, courseTea, courseDate);
				list.add(course);
			}

		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public Course selectOneCos(Course cours) {
		String sql = "select * from course where course_name='"
				+ cours.getCourseName() + "' and course_teacher='"
				+ cours.getCourseTeacher() + "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int courseid = rs.getInt("course_id");
				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				Date courseDate = rs.getDate("coursedate");
				course = new Course(courseid, courseName, courseCredit,
						courseHours, courseTea, courseDate);
			}

		} catch (SQLException e) {

			e.printStackTrace();
		}
		return course;
	}

	public PageBean courseListPage(int pageNo, int pageCount) {
		int totalCount=0;
		List<Course> list = new ArrayList<Course>();
		String sql = "select * from course limit "+((pageNo-1)*pageCount)+","+pageCount;
		String sqlCount="select count(*) from course";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int courseID = rs.getInt("course_id");
				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				Date courseDate = rs.getDate("coursedate");
				course = new Course(courseID, courseName, courseCredit,
						courseHours, courseTea, courseDate);
				list.add(course);
			}
			rs=dbCon.find(sqlCount);
			while(rs.next()){
				totalCount=rs.getInt(1);
			}
			pageBean=new PageBean(list,totalCount,pageNo,pageCount);

		} catch (SQLException e) {

			e.printStackTrace();
		}
		return pageBean;
	}

}

ScoreDaoImpl

package dao.Impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import model.PageBean;
import model.Score;
import model.ScoreCou;
import model.ScoreSum;
import dao.ScoreDao;
import db.DBCon;

public class ScoreDaoImpl implements ScoreDao {

	private Score score = null;
	private ScoreCou scoreCou = null;
	private PageBean pageBean = null;
	private ScoreSum scoreSum = null;

	private DBCon dbCon = new DBCon();

	public int addScore(Score score) {
		String sql = "insert into score(stu_num,stu_name,stu_class,course_name,score_grade,major) values('"
				+ score.getStuNum()
				+ "','"
				+ score.getStuName()
				+ "','"
				+ score.getStuClass()
				+ "','"
				+ score.getCourseName()
				+ "',"
				+ score.getScoreGrade() + ",'" + score.getMajor() + "')";
		int rs = dbCon.query(sql);
		return rs;
	}

	public int deleteScore(int scoreID) {
		String sql = "delete from score where score_id=" + scoreID;
		int rs = dbCon.query(sql);
		return rs;
	}

	public int editCos(Score score) {
		String sql = "update score set stu_num='" + score.getStuNum()
				+ "',stu_name='" + score.getStuName() + "',stu_class='"
				+ score.getStuClass() + "',course_name='"
				+ score.getCourseName() + "',score_grade="
				+ score.getScoreGrade() + ",major='" + score.getMajor()
				+ "' where score_id=" + score.getScoreID();
		int rs = dbCon.query(sql);
		return rs;
	}

	public List findAll() {
		List<Score> list = new ArrayList<Score>();
		String sql = "select * from score";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreID = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				Score score = new Score(scoreID, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);
				list.add(score);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public List findOne(String stuNum) {
		List<ScoreCou> list = new ArrayList<ScoreCou>();
		String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
				+ "from score,course where score.course_name=course.course_name and stu_num='"
				+ stuNum + "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {

				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				String major = rs.getString("major");
				Date courseDate = rs.getDate("coursedate");
				double scoreGrade = rs.getDouble("score_grade");

				ScoreCou scoreCou = new ScoreCou(courseName, courseCredit,
						courseHours, courseTea, major, courseDate, scoreGrade);
				list.add(scoreCou);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public List selectScore(int scoreID) {
		List<Score> list = new ArrayList<Score>();
		String sql = "select * from score where score_id=" + scoreID;
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreid = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				Score score = new Score(scoreid, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);
				list.add(score);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public Score selectScoreInfo(Score scor) {
		String sql = "select * from score where stu_num='" + scor.getStuNum()
				+ "' and course_name='" + scor.getCourseName() + "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreid = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				score = new Score(scoreid, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);

			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return score;
	}

	public PageBean scoreListPage(int pageNo, int pageCount, String stuNum) {
		int totalCount = 0;
		List<ScoreCou> list = new ArrayList<ScoreCou>();
		String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
				+ "from score,course where score.course_name=course.course_name and stu_num='"
				+ stuNum
				+ "' limit "
				+ ((pageNo - 1) * pageCount)
				+ ","
				+ pageCount;
		String sqlCount = "select count(*) from score,course where score.course_name=course.course_name and stu_num='"
				+ stuNum + "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {

				String courseName = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				String major = rs.getString("major");
				Date courseDate = rs.getDate("coursedate");
				double scoreGrade = rs.getDouble("score_grade");

				ScoreCou scoreCou = new ScoreCou(courseName, courseCredit,
						courseHours, courseTea, major, courseDate, scoreGrade);
				list.add(scoreCou);
			}
			rs = dbCon.find(sqlCount);
			while (rs.next()) {
				totalCount = rs.getInt(1);
			}

			pageBean = new PageBean(list, totalCount, pageNo, pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

	public PageBean scoreListPage(int pageNo, int pageCount) {
		int totalCount = 0;
		List<Score> list = new ArrayList<Score>();
		String sql = "select * from score limit " + ((pageNo - 1) * pageCount)
				+ "," + pageCount;
		String sqlCount = "select count(*) from score";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreID = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				score = new Score(scoreID, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);
				list.add(score);
			}
			rs = dbCon.find(sqlCount);
			while (rs.next()) {
				totalCount = rs.getInt(1);
			}

			pageBean = new PageBean(list, totalCount, pageNo, pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

	public List findStuOne(String stuNum, String courseName) {
		List<ScoreCou> list = new ArrayList<ScoreCou>();
		String sql = "select score.course_name,course_credit,course_hours,course_teacher,major,coursedate,score_grade "
				+ "from score,course where score.course_name=course.course_name and stu_num='"
				+ stuNum + "' and course.course_name='" + courseName + "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {

				String coursename = rs.getString("course_name");
				int courseCredit = rs.getInt("course_credit");
				int courseHours = rs.getInt("course_hours");
				String courseTea = rs.getString("course_teacher");
				String major = rs.getString("major");
				Date courseDate = rs.getDate("coursedate");
				double scoreGrade = rs.getDouble("score_grade");

				scoreCou = new ScoreCou(coursename, courseCredit, courseHours,
						courseTea, major, courseDate, scoreGrade);
				list.add(scoreCou);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public PageBean selectScoreSum(int pageNo, int pageCount) {
		int totalCount = 0;
		int i = 1;
		List<ScoreSum> list = new ArrayList<ScoreSum>();
		String sql = "select score.stu_num,score.stu_name,score.stu_class,score.major, sum(score.score_grade) as total,avg(score.score_grade) as avg "
				+ "from score group by score.stu_num order by total DESC limit "
				+ ((pageNo - 1) * pageCount) + "," + pageCount;
		String sqlCount = "select count(*) from (select stu_num from score group by score.stu_num ) as a";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int number = i;
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String major = rs.getString("major");
				double total = rs.getDouble("total");
				double avg = rs.getDouble("avg");
				scoreSum = new ScoreSum(number, stuNum, stuName, stuClass,
						major, total, avg);
				list.add(scoreSum);
				i++;
			}
			rs = dbCon.find(sqlCount);
			while (rs.next()) {
				totalCount = rs.getInt(1);
			}
			pageBean = new PageBean(list, totalCount, pageNo, pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

	public PageBean selectStuScore(int pageNo, int pageCount, Score score) {
		int totalCount = 0;
		List<Score> list = new ArrayList<Score>();
		String sql = "select * from score where stu_num like '%"
				+ score.getStuNum() + "%' and course_name like '%"
				+ score.getCourseName() + "%' and stu_name like '%"
				+ score.getStuName() + "%' and stu_class like '%"
				+ score.getStuClass() + "%' and major like '%"
				+ score.getMajor() + "%' limit " + ((pageNo - 1) * pageCount)
				+ "," + pageCount;
		String sqlCount = "select count(*) from score where stu_num like '%"
				+ score.getStuNum() + "%' and course_name like '%"
				+ score.getCourseName() + "%' and stu_name like '%"
				+ score.getStuName() + "%' and stu_class like '%"
				+ score.getStuClass() + "%' and major like '%"
				+ score.getMajor() + "%'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreID = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				score = new Score(scoreID, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);
				list.add(score);
			}
			rs = dbCon.find(sqlCount);
			while (rs.next()) {
				totalCount = rs.getInt(1);
			}

			pageBean = new PageBean(list, totalCount, pageNo, pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

	public PageBean selectTeaScore(int pageNo, int pageCount, String teaName,
			Score score) {
		int totalCount = 0;
		List<Score> list = new ArrayList<Score>();
		String sql = "select score.score_id,score.stu_num,score.stu_name,score.stu_class,score.course_name,score.score_grade,score.major from score,course where score.course_name=course.course_name and course.course_teacher='"
				+ teaName
				+ "'  and score.stu_name like '%"
				+ score.getStuName()
				+ "%' and score.stu_class like '%"
				+ score.getStuClass()
				+ "%' and score.stu_num like '%"
				+ score.getStuNum()
				+ "%' limit "
				+ ((pageNo - 1) * pageCount)
				+ "," + pageCount;
		String sqlCount = "select count(*) from score,course where score.course_name=course.course_name and course.course_teacher='"
				+ teaName 
				+ "'  and score.stu_name like '%"
				+ score.getStuName()
				+ "%' and score.stu_class like '%"
				+ score.getStuClass()
				+ "%' and score.stu_num like '%"
				+ score.getStuNum()
				+ "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int scoreID = rs.getInt("score_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuClass = rs.getString("stu_class");
				String courseName = rs.getString("course_name");
				double scoreGrade = rs.getDouble("score_grade");
				String major = rs.getString("major");
				score = new Score(scoreID, stuNum, stuName, stuClass,
						courseName, scoreGrade, major);
				list.add(score);
			}
			rs = dbCon.find(sqlCount);
			while (rs.next()) {
				totalCount = rs.getInt(1);
			}

			pageBean = new PageBean(list, totalCount, pageNo, pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

}

StudentDaoImpl

package dao.Impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import model.PageBean;
import model.Student;
import dao.StudentDao;
import db.DBCon;

public class StudentDaoImpl implements StudentDao {

	private DBCon dbCon = new DBCon();
	private Student student;
	private PageBean pageBean;

	public int addStu(Student student) {
		String sql = "insert into student(stu_num,stu_name,stu_sex,stu_age,stu_class,major,department) values('"
				+ student.getStuNum()
				+ "','"
				+ student.getStuName()
				+ "','"
				+ student.getStuSex()
				+ "',"
				+ student.getStuAge()
				+ ",'"
				+ student.getStuClass()
				+ "','"
				+ student.getMajor()
				+ "','"
				+ student.getDepartment() + "')";
		int rs = dbCon.query(sql);

		return rs;
	}

	public int deleteStu(String stuNum) {
		String sql = "delete from student where stu_num='" + stuNum + "'";
		int rs = dbCon.query(sql);
		return rs;
	}

	public int editStu(Student student) {
		String sql = "update student set stu_name='" + student.getStuName()
				+ "',stu_sex='" + student.getStuSex() + "',stu_age="
				+ student.getStuAge() + ",stu_class='" + student.getStuClass()
				+ "',major='" + student.getMajor() + "',department='"
				+ student.getDepartment() + "' where stu_num='"
				+ student.getStuNum() + "'";
		int rs=dbCon.query(sql);
		return rs;
	}

	public List findAll() {
		List<Student> list = new ArrayList<Student>();
		String sql = "select * from student";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int stuID = rs.getInt("stu_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuSex = rs.getString("stu_sex");
				int stuAge = rs.getInt("stu_age");
				String stuClass = rs.getString("stu_class");
				String major = rs.getString("major");
				String department = rs.getString("department");
				student = new Student(stuID, stuNum, stuName, stuSex, stuAge,
						stuClass, major, department);
				list.add(student);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public List findOne(String stuNum) {
		List<Student> list = new ArrayList<Student>();
		String sql="select * from student where stu_num='"+stuNum+"'";
		ResultSet rs=dbCon.find(sql);
		try {
			while(rs.next()){
				int stuID = rs.getInt("stu_id");
				String stunum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuSex = rs.getString("stu_sex");
				int stuAge = rs.getInt("stu_age");
				String stuClass = rs.getString("stu_class");
				String major = rs.getString("major");
				String department = rs.getString("department");
				student = new Student(stuID, stunum, stuName, stuSex, stuAge,
						stuClass, major, department);
				list.add(student);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	//pageNo当前页码,pageCount每页显示总条数
	public PageBean stuListPage(int pageNo, int pageCount) {
		int totalCount=0;
		List<Student> list = new ArrayList<Student>();
		String sql="select * from student limit "+((pageNo-1)*pageCount)+","+pageCount;
		String sqlCount="select count(*) from student";
		
		try {
			ResultSet rs=dbCon.find(sql);
			while(rs.next()){
				int stuID = rs.getInt("stu_id");
				String stuNum = rs.getString("stu_num");
				String stuName = rs.getString("stu_name");
				String stuSex = rs.getString("stu_sex");
				int stuAge = rs.getInt("stu_age");
				String stuClass = rs.getString("stu_class");
				String major = rs.getString("major");
				String department = rs.getString("department");
				student = new Student(stuID, stuNum, stuName, stuSex, stuAge,
						stuClass, major, department);
				list.add(student);
			}
			rs=dbCon.find(sqlCount);
			while(rs.next()){
				totalCount=rs.getInt(1); 
			}
			pageBean=new PageBean(list ,  totalCount,  pageNo,  pageCount);
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		return pageBean;
	}

}

TeacherDaoImpl

package dao.Impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import model.PageBean;
import model.Student;
import model.Teacher;
import dao.TeacherDao;
import db.DBCon;

public class TeacherDaoImpl implements TeacherDao{
	
	private DBCon dbCon = new DBCon();
	private Teacher teacher;
	private PageBean pageBean;

	public int addTea(Teacher teacher) {
		String sql = "insert into teacher(tea_num,tea_name,tea_sex,tea_age,tea_course,major,department) values('"
				+ teacher.getTeaNum()
				+ "','"
				+ teacher.getTeaName()
				+ "','"
				+ teacher.getTeaSex()
				+ "',"
				+ teacher.getTeaAge()
				+ ",'"
				+ teacher.getTeaCourse()
				+ "','"
				+ teacher.getMajor()
				+ "','"
				+ teacher.getDepartment() + "')";
		int rs = dbCon.query(sql);

		return rs;
	}

	public int deleteTea(String teaNum) {
		String sql = "delete from teacher where tea_num='" + teaNum + "'";
		int rs = dbCon.query(sql);
		return rs;
	}

	public int editTea(Teacher teacher) {
		String sql = "update teacher set tea_name='" + teacher.getTeaName()
				+ "',tea_sex='" + teacher.getTeaSex() + "',tea_age="
				+ teacher.getTeaAge() + ",tea_course='" + teacher.getTeaCourse()
				+ "',major='" + teacher.getMajor() + "',department='"
				+ teacher.getDepartment() + "' where tea_num='"
				+ teacher.getTeaNum() + "'";
		int rs=dbCon.query(sql);
		return rs;
	}

	public List findAll() {
		List<Teacher> list=new ArrayList<Teacher>();
		String sql="select * from teacher";
		ResultSet rs=dbCon.find(sql);
		try {
			while (rs.next()) {
				int teaID = rs.getInt("tea_id");
				String teaNum = rs.getString("tea_num");
				String teaName = rs.getString("tea_name");
				String teaSex = rs.getString("tea_sex");
				int teaAge = rs.getInt("tea_age");
				String teaCourse = rs.getString("tea_course");
				String major = rs.getString("major");
				String department = rs.getString("department");
				teacher = new Teacher(teaID, teaNum, teaName, teaSex, teaAge,
						teaCourse, major, department);
				list.add(teacher);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public List findOne(String teaNum) {
		List<Teacher> list=new ArrayList<Teacher>();
		String sql="select * from teacher where tea_num='"+teaNum+"'";
		ResultSet rs=dbCon.find(sql);
		try {
			while (rs.next()) {
				int teaID = rs.getInt("tea_id");
				String teanum = rs.getString("tea_num");
				String teaName = rs.getString("tea_name");
				String teaSex = rs.getString("tea_sex");
				int teaAge = rs.getInt("tea_age");
				String teaCourse = rs.getString("tea_course");
				String major = rs.getString("major");
				String department = rs.getString("department");
				teacher = new Teacher(teaID, teanum, teaName, teaSex, teaAge,
						teaCourse, major, department);
				list.add(teacher);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	public PageBean teaListPage(int pageNo, int pageCount) {
		List<Teacher> list=new ArrayList<Teacher>();
		int totalCount=0;
		String sql="select * from teacher limit "+((pageNo-1)*totalCount)+","+totalCount;
		String sqlCount="select count(*) from teacher";
		ResultSet rs=dbCon.find(sql);
		try {
			while(rs.next()){
				int teaID = rs.getInt("tea_id");
				String teanum = rs.getString("tea_num");
				String teaName = rs.getString("tea_name");
				String teaSex = rs.getString("tea_sex");
				int teaAge = rs.getInt("tea_age");
				String teaCourse = rs.getString("tea_course");
				String major = rs.getString("major");
				String department = rs.getString("department");
				teacher = new Teacher(teaID, teanum, teaName, teaSex, teaAge,
						teaCourse, major, department);
				list.add(teacher);
			}
			rs=dbCon.find(sqlCount);
			while(rs.next()){
				totalCount=rs.getInt(1);
			}
		} catch (SQLException e) {
			dbCon.close();
			e.printStackTrace();
		}
		pageBean=new PageBean(list,totalCount,pageNo,pageCount);
		return pageBean;
	}

}

UserDaoImpl

package dao.Impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import model.UsRole;
import model.User;
import dao.UserDao;
import db.DBCon;

public class UserDaoImpl implements UserDao {
	private DBCon dbCon = new DBCon();
	private User user;
	private UsRole usRole;

	public User login(User user) {
		String sql = "select *from user where user_num='" + user.getUserNum()
				+ "'";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int userID = rs.getInt("user_id");
				String userNum = rs.getString("user_num");
				String userName = rs.getString("user_name");
				String pwd = rs.getString("password");
				String phone = rs.getString("phone");
				int roleID = rs.getInt("role_id");
				user = new User(userID, userNum, userName, pwd, phone, roleID);
			}

		} catch (SQLException e) {

			e.printStackTrace();
		}
		return user;
	}

	public int editPwd(User user) {
		String sql = "update user set password='" + user.getPassword()
				+ "' where user_num='" + user.getUserNum() + "'";
		int rs = dbCon.query(sql);
		return rs;
	}

	public int addUser(User user) {
		String sql = "insert into user(user_num,user_name,password,phone,role_id) values('"
				+ user.getUserNum()
				+ "','"
				+ user.getUserName()
				+ "','"
				+ user.getPassword()
				+ "',"
				+ user.getPhone()
				+ ","
				+ user.getRoleID() + ")";
		int rs = dbCon.query(sql);
		return rs;
	}

	public List findAll() {
		List<UsRole> list = new ArrayList<UsRole>();
		String sql = "select user_id,user_num,user_name,password,phone,role_name from user,role where user.role_id=role.role_id";
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int userID = rs.getInt("user_id");
				String userNum = rs.getString("user_num");
				String userName = rs.getString("user_name");
				String pwd = rs.getString("password");
				String phone = rs.getString("phone");
				String roleName = rs.getString("role_name");
				usRole = new UsRole(userID, userNum, userName, pwd, phone,
						roleName);
				list.add(usRole);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public List selectOneUser(int userID) {
		List<User> list = new ArrayList<User>();
		String sql = "select * from user where user_id=" + userID;
		ResultSet rs = dbCon.find(sql);
		try {
			while (rs.next()) {
				int userid = rs.getInt("user_id");
				String userNum = rs.getString("user_num");
				String userName = rs.getString("user_name");
				String pwd = rs.getString("password");
				String phone = rs.getString("phone");
				int roleID = rs.getInt("role_id");
				user = new User(userID, userNum, userName, pwd, phone, roleID);
				list.add(user);
			}
		} catch (SQLException e) {

			e.printStackTrace();
		}
		return list;
	}

	public int editUser(User user) {
		String sql = "update user set user_name='" + user.getUserName()
				+ "',password=" + user.getPassword() + ",phone='"
				+ user.getPhone() + "' where user_num='" + user.getUserNum()
				+ "'";
		int rs = dbCon.query(sql);
		return rs;
	}

}

DBCon

package db;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;


public class DBCon {
	Connection con = null;
	Statement st = null;
	ResultSet rs = null;
	String driver=null;
	String url = null;
	String username = null;
	String password = null;

	public Connection dbCon() {
		try {
			InputStream is=DBCon.class.getClassLoader().getResourceAsStream("db.properties");
			Properties prop=new Properties();
			try {
				prop.load(is);
				driver=prop.getProperty("driver");
				url=prop.getProperty("url");
				username=prop.getProperty("username");
				password=prop.getProperty("password");
				
			} catch (IOException e1) {
				
				e1.printStackTrace();
			}
			Class.forName(driver);
			/*Class.forName("com.mysql.jdbc.Driver");
			url = "jdbc:mysql:///sams?useUnicode=true&characterEncoding=utf8";
			username = "root";
			password = "root";*/
			try {
				con = DriverManager.getConnection(url, username, password);
			} catch (SQLException e) {

				e.printStackTrace();
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return con;
	}

	/*
	 * 增删改
	 */
	public int query(String sql) {
		int rs = 0;
		con = dbCon();
		try {
			st = con.createStatement();
			rs = st.executeUpdate(sql);
		} catch (SQLException e) {
			close();
			e.printStackTrace();
		}

		return rs;
	}

	/*
	 * 查
	 */
	public ResultSet find(String sql) {

		try {
			con = dbCon();
			st = con.createStatement();
			rs = st.executeQuery(sql);
		} catch (SQLException e) {
			close();
			e.printStackTrace();
		}
		return rs;
	}

	/*
	 * 关闭数据库
	 */
	public void close() {
		try {
			if (rs != null)
				rs.close();
			if (st != null)
				st.close();
			if (con != null)
				con.close();
		} catch (SQLException e) {

			e.printStackTrace();
		}
	}
}

register.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>注册页面</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
  </head>
  
	<style type="text/css">
		html, body {
				margin: 0;
				padding: 0;
				width: 100%;
				height: 100%;
				background-image: linear-gradient(to bottom, #243949 0%, #517fa4 100%);
				overflow: hidden;
			}
		canvas{
			position: absolute;
			top: 0;
		}
		.div_ads {
			z-index: 3;
			width: 30%;
			margin: 0 auto;
			margin-top: 50px;
			border: 1px solid #ccc;
			background: rgba(238, 235, 235,1);
			position: relative;
			border-radius: 6px;
			height: 650px;
		}
	
		table {
			position: absolute;
			left: 10%;
		}
		table tr td {
			text-align: center;
			height:44px;
			width: 8%;
			text-align: center;
		}
		h3{
			text-align: center;
			padding-top: 20px;
		}
		hr{
			margin-left: 15px;
			margin-right: 15px;
			background: #ccc;
		}
		.btn1{
			background: #afc5d6;
		}
		font{
			font-size: .7rem;
			float: left;
		}
	</style>


<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/particle-bg.umd.min.js"></script>
<script type="text/javascript">
window.onload = function(){
	particleBg('body', {
			color: 'rgba(255, 255, 255, 0.5)'
		});
}
</script>
<script type="text/javascript">
	
	function AjaxChecked(){
		var xmlHttpRequest=null;
		if(XMLHttpRequest){
			xmlHttpRequest=new XMLHttpRequest();
		}else{
			xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(xmlHttpRequest!=null){
			//拿到账号
			var stuNum=document.getElementById("stuNum");
			if(stuNum.value==""){
				document.getElementById("stuNumcheck").innerHTML = "学号不能为空";
				return;
			}else{
			
				var url="ServletRegisterStu?stuNum="+stuNum.value;
				xmlHttpRequest.open("get",url,true);
				
				xmlHttpRequest.send();
				xmlHttpRequest.onreadystatechange=function(){
					if(xmlHttpRequest.readyState==4 && xmlHttpRequest.status==200){
						var text = xmlHttpRequest.responseText;
						//alert(text);
						document.getElementById("stuNumcheck").innerHTML = text;
					}
				};
			}
		}
	}
	
	function namecheck(){
		var stuName=document.getElementById("stuName").value;
		var rename=/^[一-龥]+$/gi;          //中文判断
		if(stuName==""){
			document.getElementById("stuNamecheck").innerHTML = "用户名不能为空";
		}
		else if (!rename.test(stuName))
		{
			document.getElementById("stuNamecheck").innerHTML = "请输入中文名,如:王文军";
		}else{
			document.getElementById("stuNamecheck").innerHTML = "正确";
		}
	}
	
	function pwdcheck(){
		var pwd1=document.getElementById("password").value;
		if(pwd1==""){
			document.getElementById("stuPwdcheck").innerHTML = "密码不能为空";
		}else if(pwd1.length<6){
			document.getElementById("stuPwdcheck").innerHTML = "密码不能小于六位";
		}else {
			document.getElementById("stuPwdcheck").innerHTML = "正确";
		}
	}
	
	function pwdc(){
		
		var pwd1=document.getElementById("password").value;
		var pwd2=document.getElementById("pwd").value;
		
		if(pwd1==""){
			document.getElementById("stuPwdrcheck").innerHTML = "确认密码不能为空";
		}else if(pwd1!=pwd2){
			document.getElementById("stuPwdrcheck").innerHTML = "两次密码不一致";
		}else {
			document.getElementById("stuPwdrcheck").innerHTML = "正确";
		}
	}
</script>
</head>

<body>
	 <form action="ServletRegistersStudent" method="post"> 
	
		<div class="div_ads">
		<font>${msg}</font><h3>注册页面</h3>
		<hr class="color:black">
		
			<table>
				<tr>
					<td colspan="2"><input type="text" name="stuNum" class="put form-control" id="stuNum" onblur="AjaxChecked();" placeholder="学号" aria-describedby="basic-addon1"/></td>
					<td><font id="stuNumcheck"></font></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="text" name="stuName" class="put form-control" id="stuName" onblur="namecheck();" placeholder="姓名" aria-describedby="basic-addon1"/></td>
					<td><font id="stuNamecheck"></font></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="password" name="password" class="put form-control" id="password" onblur="pwdcheck();"  placeholder="密码" aria-describedby="basic-addon1"/></td>
					<td><font id="stuPwdcheck"></font></td>
				</tr>
				<tr>
				
					<td colspan="2"><input type="password" name="pwd" class="put form-control" id="pwd" onblur="pwdc();"  placeholder="确认密码" aria-describedby="basic-addon1"/></td>
					<td><font id="stuPwdrcheck"></font></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="radio"  name="stuSex" value="男" checked="checked" />男&nbsp;&nbsp;
						<input type="radio" name="stuSex" value="女" />女
					</td>
				</tr>
				<tr>
				
					<td colspan="2"><input type="text" name="stuAge" class="put form-control" placeholder="年龄" aria-describedby="basic-addon1"/></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="text" name="stuClass" class="put form-control" placeholder="班级" aria-describedby="basic-addon1"/></td>
				</tr>
				<tr>
				
					<td colspan="2"><input type="text" name="major" class="put form-control" placeholder="专业" aria-describedby="basic-addon1"/></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="text" name="department" class="put form-control" placeholder="院系" aria-describedby="basic-addon1"/></td>
				</tr>
				<tr>
					
					<td colspan="2"><input type="text" name="phone" class="put form-control" placeholder="电话" aria-describedby="basic-addon1"/></td>
				</tr>
				<tr>
					<td colspan="2"><input type="hidden" name="role" value="0" /></td>
				</tr>
				<tr>
					<td><input type="submit" value="注册" class="putb btn btn1" /></td>
					<td><input type="reset" value="清空" class="putb btn btn1" /></td>
				</tr>
			</table>
		</div>
	 </form> 
</body>
</html>

login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>登陆</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
html, body {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      background-image: linear-gradient(to bottom, #243949 0%, #517fa4 100%);
      overflow: hidden;
    }
canvas{
	position: absolute;
	top: 0;
	z-index: -1;
}
#_top {
	text-align: center;
	height: 100px;
	font-size: 30px;
	padding-top: 30px;
	letter-spacing: 10px; /*字与字之间的间距*/
}
#_top span{
	color: aliceblue;
}

.div_body {
	height: 400px;
	width: 30%;
	margin: 10% auto;
	position: relative;
	/*background:rgba(255,255,255, 0.3);*/
	background: #fff;
	/*box-shadow: whitesmoke 5px 5px 50px 5px;*/
	border-radius: 6px;
	z-index: 2;
}
#_body {
	width: 100%;
	text-align: center;
}
.msg{
	padding-top: 20px;
	color: #374b5d;
	height: 40px;
}
table{
	margin: 0 10%;
	width: 100%;
	height: 85%;
}
table tr{
	width: 100%;
	height: 15%;
}
table tr td{
	font-size: 20px;
	width: 100%;
}
.input{
	width: 80%;
	height: 55%;
	border-radius: 10px;
	text-align: center;
	font-size: 15px;
	border:1px solid #ccc;
	color: #ccc;

}
.btn {
    color: #ffffff;
    background-color: #40586d;
    border-color: #374b5d;
		width:20%;
		margin-right: 8%;
}
.check{
	width: 13%;

}
</style>
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/particle-bg.umd.min.js"></script>

<script type="text/javaScript">
window.onload = function() {
	particleBg('body', {
    color: 'rgba(255, 255, 255, 0.5)'
  });
}
</script>
</head>

<body>
	<div class="div_body">
		<div id="_body">
		<h3 class="msg" style="cursor:default">${massage }</h3>
			<form action="ServletLogin" method="post"
				onsubmit="return checked(this)">
				<table>
					<tr>
						<td><input class="input" type="text" name="ID" placeholder="账号">
						</td>
					</tr>
					<tr>
						<td><input class="input" type="password" name="pwd" placeholder="密码">
						</td>
					</tr>
					<tr>
						<td>
							<input class="check" type="radio" name="role" value="0" checked="checked">学生
							<input class="check" type="radio" name="role" value="1">教师 
							<input class="check" type="radio" name="role" value="2">管理员
						</td>
					</tr>
					<tr>
						<td>
							<input class="btn" type="submit" value="登录">
							<input class="btn" type="button" name="register" value="注册"
							onclick="window.open('register/register.jsp')">
							<input class="btn" type="reset" value="取消">
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>

selectScore.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<style type="text/css">
.div_select,.div_ads {
	width:75%;
	margin: auto;
	margin-top: 50px;
	margin-left:20%;
}
.attr{
	font:bold;
}
a{
	cursor: pointer
}
#form1{
width:200px;
display: inline-block
}
#pageNo{
width:200px;
display: inline-block
}
</style>
<link rel="stylesheet" href="css/bootstrap.min.css">

<script type="text/javascript">

	function page(s){
		var frm=document.getElementById("frm");
		var pageNo=document.getElementById("pageNo");
		pageNo.value=s;
		frm.submit();
	}
	</script>
	</head>
<body>
		
		<div class="div_select">
				<form action="ServletOneStudentScore" method="post">
				课程名:<input type="text" class="form-control" id="form1"  name="cosName"/> <input type="submit" class="btn btn-primary" value="查询" />
				</form>
			</div>
			<form action="ServletFindStudentScore" method="post" id="frm"></form>
		<div class="div_ads">
				<div class="panel panel-default">
						<!-- Default panel contents -->
						<div class="panel-heading">
							成绩信息
						</div>
					  
						<!-- Table -->
					
						<table class="table" style="width: 100%">
							<tr>
								<td><b>科目</b></td>
								<td><b>学分</b></td>
								<td><b>学时</b></td>
								<td><b>任课教师</b></td>
								<td><b>专业</b></td>
								<td><b>开课时间</b></td>
								<td><b>成绩</b></td>
							</tr>
							<c:forEach var="list" items="${list.pbjs }">
								<tr>
										<td>${list.getCourseName() }</td>
										<td>${list.getCourseCredit() }</td>
										<td>${list.getCourseHours() }</td>
										<td>${list.getCourseTeacher() }</td>
										<td>${list.getMajor() }</td>
										<td>${list.getCourseDate() }</td>
										<td>${list.getScoreGrade() }</td>
											
								</tr>
								</c:forEach>
							<tr>
							<td colspan="7"><a onclick="page(1);">首页</a> 
							<c:if test="${list.isPrevious() }"> 
								<a onclick="page(${list.pageNo-1});">上一页</a>
							</c:if> 
							<c:if test="${list.isNext() }">
								<a onclick="page(${list.pageNo+1});">下一页</a>
							</c:if> 
							<a onclick="page(${list.totalPage });">最后一页</a> <br />
							 跳转到:<input id="pageNo" type="text"  class="form-control form1"  name="pageNo" value="${list.pageNo }" />
							每页记录数:<input type="text" name="pageCount"  class="form-control" id="form1"  value="${list.pageCount }" /> 
							<input type="hidden" name="totalPage" value="${list.totalPage }" id='form1' /> 
							<input type="submit" class="btn btn-primary" value="跳转" /> 共有${list.totalPage }页</td>
						</tr>
						</table>
					
					  </div>
		</div>
	</form>
<script src="js/jquery-3.3.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

四、其他

1.其他系统实现

1.JavaWeb系统系列实现

Java+JSP实现学生图书管理系统

Java+JSP实现学生信息管理系统

Java+JSP实现用户信息管理系统

Java+Servlet+JSP实现航空订票系统

Java+Servlet+JSP实现学生选课管理系统

Java+Servlet+JSP实现学生成绩管理系统-1

Java+Servlet+JSP实现宠物诊所管理系统

Java+SSM+Easyui实现网上考试系统

Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统

2.JavaSwing系统系列实现

Java+Swing实现斗地主游戏

Java+Swing实现图书管理系统

Java+Swing实现医院管理系统

Java+Swing实现仓库管理系统-1

Java+Swing实现仓库管理系统-2

Java+Swing实现考试管理系统

Java+Swing实现通讯录管理系统

Java+Swing实现停车场管理系统

Java+Swing实现学生信息管理系统

Java+Swing实现学生宿舍管理系统

Java+Swing实现学生选课管理系统

Java+Swing实现学生成绩管理系统

Java+Swing实现学校教材管理系统

Java+Swing实现学校教务管理系统

Java+Swing实现企业人事管理系统

Java+Swing实现电子相册管理系统

Java+Swing实现超市管理系统-TXT存储数据

Java+Swing实现自助取款机系统-TXT存储数据

Java+Swing实现宠物商店管理系统-TXT存储数据

2.获取源码

点击以下链接获取源码,数据库文件在sql文件下面。

Java+Servlet+JSP+Bootstrap+Mysql学生成绩管理系统源码

3.运行项目

请点击以下链接,部署你的项目。

IDEA如何导入JavaWeb项目超详细视频教程

4.备注

如有侵权请联系我删除。

5.支持博主

如果您觉得此文对您有帮助,请点赞加关注。祝您生活愉快!想要获取其他资源可关注左侧微信公众号获取!

  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章      下一篇文章      查看所有文章
加:2022-02-27 10:57:09  更:2022-02-27 10:58:52 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 11:56:27-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码