目录
一、系统介绍
1.开发环境
2.技术选型
3.系统功能
4.数据库
5.工程截图
二、系统展示
1.登录界面
2.学生-主页面
3.学生-缺勤记录
4.学生-修改密码
5.宿舍管理员-主页面
6.宿舍管理员-学生查看
7.宿舍管理员-缺勤记录
8.宿舍管理员-修改密码
9.系统管理员-主页面
10.系统管理员-宿舍管理员管理
11.系统管理员-学生管理
12.系统管理员-宿舍楼管理
13.系统管理员-缺勤记录
14.系统管理员-修改密码
三、部分代码
DormBuildDao
DormManagerDao
RecordDao
StudentDao
UserDao
PropertiesUtil
login.jsp
mainAdmin.jsp
mainManager.jsp
mainStudent.jsp
四、其他
1.其他系统实现
1.JavaWeb系统系列实现
2.JavaSwing系统系列实现
2.获取源码
3.运行项目
4.备注
5.支持博主
开发工具:IDEA2018.2
JDK版本:jdk1.8
Mysql版本:8.0.13
1.后端:使用Java+Servlet进行开发,使用过滤器来验证用户是否登录,使用MVC进行分层。
2.数据库:使用JDBC连接数据库,使用getResourceAsStream获取数据库配置文件的信息。
3.前端:使用Bootstrap作为前端框架来开发,使用到jstl来遍历数据。jsp来展示页面。
1.学生
1.登录系统
2.缺勤记录
缺勤记录查询
3.修改密码
4.退出系统
2.宿舍管理员
1.登录系统
2.学生查看
查看学生信息
3.缺勤记录管理
缺勤记录的增删改查。
4.修改密码
5.退出系统
3.系统管理员
1.登录系统
2.宿舍管理员管理
宿舍管理员信息的增删改查。
3.学生信息管理
学生信息的增删改查。
4.宿舍楼信息管理
宿舍楼信息的增删改查。
5.缺勤记录管理
缺勤记录删除
6.修改密码
7.退出系统
/*
Navicat Premium Data Transfer
Source Server : Mysql
Source Server Type : MySQL
Source Server Version : 80013
Source Host : localhost:3306
Source Schema : jsp_servlet_drom
Target Server Type : MySQL
Target Server Version : 80013
File Encoding : 65001
Date: 22/07/2021 20:46:38
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for t_admin
-- ----------------------------
DROP TABLE IF EXISTS `t_admin`;
CREATE TABLE `t_admin` (
`adminId` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tel` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`adminId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_admin
-- ----------------------------
INSERT INTO `t_admin` VALUES (1, 'admin', 'admin', '管理员', '男', '1828888888');
-- ----------------------------
-- Table structure for t_dorm
-- ----------------------------
DROP TABLE IF EXISTS `t_dorm`;
CREATE TABLE `t_dorm` (
`dormId` int(11) NOT NULL AUTO_INCREMENT,
`dormBuildId` int(11) NULL DEFAULT NULL,
`dormName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormType` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormNumber` int(11) NULL DEFAULT NULL,
`dormTel` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`dormId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_dorm
-- ----------------------------
INSERT INTO `t_dorm` VALUES (1, 1, '220', '男', 4, '110');
-- ----------------------------
-- Table structure for t_dormbuild
-- ----------------------------
DROP TABLE IF EXISTS `t_dormbuild`;
CREATE TABLE `t_dormbuild` (
`dormBuildId` int(11) NOT NULL AUTO_INCREMENT,
`dormBuildName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormBuildDetail` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`dormBuildId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_dormbuild
-- ----------------------------
INSERT INTO `t_dormbuild` VALUES (1, '1栋', '一栋信息介绍');
INSERT INTO `t_dormbuild` VALUES (2, '2栋', '二栋信息介绍');
INSERT INTO `t_dormbuild` VALUES (3, '3栋', '三栋信息介绍');
INSERT INTO `t_dormbuild` VALUES (4, '4栋', '四栋信息介绍');
INSERT INTO `t_dormbuild` VALUES (5, '5栋', '五栋信息介绍');
-- ----------------------------
-- Table structure for t_dormmanager
-- ----------------------------
DROP TABLE IF EXISTS `t_dormmanager`;
CREATE TABLE `t_dormmanager` (
`dormManId` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormBuildId` int(11) NULL DEFAULT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sex` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tel` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`dormManId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_dormmanager
-- ----------------------------
INSERT INTO `t_dormmanager` VALUES (1, 'dromadmin', '123456', 4, '宿舍管理员', '男', '18212346589');
-- ----------------------------
-- Table structure for t_record
-- ----------------------------
DROP TABLE IF EXISTS `t_record`;
CREATE TABLE `t_record` (
`recordId` int(11) NOT NULL AUTO_INCREMENT,
`studentNumber` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`studentName` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormBuildId` int(11) NULL DEFAULT NULL,
`dormName` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`date` date NULL DEFAULT NULL,
`detail` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`recordId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_record
-- ----------------------------
INSERT INTO `t_record` VALUES (1, '001', '李四', 4, '120', '2014-01-01', '回家');
-- ----------------------------
-- Table structure for t_student
-- ----------------------------
DROP TABLE IF EXISTS `t_student`;
CREATE TABLE `t_student` (
`studentId` int(11) NOT NULL AUTO_INCREMENT,
`stuNum` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`password` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`dormBuildId` int(11) NULL DEFAULT NULL,
`dormName` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tel` varchar(15) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`studentId`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 32 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_student
-- ----------------------------
INSERT INTO `t_student` VALUES (1, '001', '123456', '李四', 4, '120', '男', '123456');
INSERT INTO `t_student` VALUES (2, '002', '123456', '王五', 5, '201', '男', '123456');
SET FOREIGN_KEY_CHECKS = 1;
package com.lero.dao;
import com.lero.model.DormBuild;
import com.lero.model.DormManager;
import com.lero.model.PageBean;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class DormBuildDao {
public static String dormBuildName(Connection con, int dormBuildId) throws Exception {
String sql = "select * from t_dormBuild where dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setInt(1, dormBuildId);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getString("dormBuildName");
}
return null;
}
public List dormBuildList(Connection con, PageBean pageBean, DormBuild s_dormBuild) throws Exception {
List dormBuildList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_dormBuild t1");
if (StringUtil.isNotEmpty(s_dormBuild.getDormBuildName())) {
sb.append(" where t1.dormBuildName like '%" + s_dormBuild.getDormBuildName() + "%'");
}
if (pageBean != null) {
sb.append(" limit " + pageBean.getStart() + "," + pageBean.getPageSize());
}
PreparedStatement pstmt = con.prepareStatement(sb.toString());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormBuild dormBuild = new DormBuild();
dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
dormBuild.setDormBuildName(rs.getString("dormBuildName"));
dormBuild.setDetail(rs.getString("dormBuildDetail"));
dormBuildList.add(dormBuild);
}
return dormBuildList;
}
public int dormBuildCount(Connection con, DormBuild s_dormBuild) throws Exception {
StringBuffer sb = new StringBuffer("select count(*) as total from t_dormBuild t1");
if (StringUtil.isNotEmpty(s_dormBuild.getDormBuildName())) {
sb.append(" where t1.dormBuildName like '%" + s_dormBuild.getDormBuildName() + "%'");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getInt("total");
} else {
return 0;
}
}
public DormBuild dormBuildShow(Connection con, String dormBuildId) throws Exception {
String sql = "select * from t_dormBuild t1 where t1.dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuildId);
ResultSet rs = pstmt.executeQuery();
DormBuild dormBuild = new DormBuild();
if (rs.next()) {
dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
dormBuild.setDormBuildName(rs.getString("dormBuildName"));
dormBuild.setDetail(rs.getString("dormBuildDetail"));
}
return dormBuild;
}
public int dormBuildAdd(Connection con, DormBuild dormBuild) throws Exception {
String sql = "insert into t_dormBuild values(null,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuild.getDormBuildName());
pstmt.setString(2, dormBuild.getDetail());
return pstmt.executeUpdate();
}
public int dormBuildDelete(Connection con, String dormBuildId) throws Exception {
String sql = "delete from t_dormBuild where dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuildId);
return pstmt.executeUpdate();
}
public int dormBuildUpdate(Connection con, DormBuild dormBuild) throws Exception {
String sql = "update t_dormBuild set dormBuildName=?,dormBuildDetail=? where dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuild.getDormBuildName());
pstmt.setString(2, dormBuild.getDetail());
pstmt.setInt(3, dormBuild.getDormBuildId());
return pstmt.executeUpdate();
}
public boolean existManOrDormWithId(Connection con, String dormBuildId) throws Exception {
boolean isExist = false;
// String sql="select * from t_dormBuild,t_dormManager,t_connection where dormManId=managerId and dormBuildId=buildId and dormBuildId=?";
String sql = "select *from t_dormManager where dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuildId);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
isExist = true;
} else {
isExist = false;
}
String sql1 = "select * from t_dormBuild t1,t_dorm t2 where t1.dormBuildId=t2.dormBuildId and t1.dormBuildId=?";
PreparedStatement p = con.prepareStatement(sql1);
p.setString(1, dormBuildId);
ResultSet r = pstmt.executeQuery();
if (r.next()) {
return isExist;
} else {
return false;
}
}
public List dormManWithoutBuild(Connection con) throws Exception {
List dormManagerList = new ArrayList();
String sql = "SELECT * FROM t_dormManager WHERE dormBuildId IS NULL OR dormBuildId=0";
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormManager dormManager = new DormManager();
dormManager.setDormBuildId(rs.getInt("dormBuildId"));
dormManager.setDormManagerId(rs.getInt("dormManId"));
dormManager.setName(rs.getString("name"));
dormManager.setUserName(rs.getString("userName"));
dormManager.setSex(rs.getString("sex"));
dormManager.setTel(rs.getString("tel"));
dormManagerList.add(dormManager);
}
return dormManagerList;
}
public List dormManWithBuildId(Connection con, String dormBuildId) throws Exception {
List dormManagerList = new ArrayList();
String sql = "select *from t_dormManager where dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuildId);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormManager dormManager = new DormManager();
dormManager.setDormBuildId(rs.getInt("dormBuildId"));
dormManager.setDormManagerId(rs.getInt("dormManId"));
dormManager.setName(rs.getString("name"));
dormManager.setUserName(rs.getString("userName"));
dormManager.setSex(rs.getString("sex"));
dormManager.setTel(rs.getString("tel"));
dormManagerList.add(dormManager);
}
return dormManagerList;
}
public int managerUpdateWithId(Connection con, String dormManagerId, String dormBuildId) throws Exception {
String sql = "update t_dormManager set dormBuildId=? where dormManId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormBuildId);
pstmt.setString(2, dormManagerId);
return pstmt.executeUpdate();
}
}
package com.lero.dao;
import com.lero.model.DormManager;
import com.lero.model.PageBean;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class DormManagerDao {
public List dormManagerList(Connection con, PageBean pageBean, DormManager s_dormManager) throws Exception {
List dormManagerList = new ArrayList();
StringBuffer sb = new StringBuffer("SELECT * FROM t_dormManager t1 ORDER BY t1.userName");
if (StringUtil.isNotEmpty(s_dormManager.getName())) {
sb.append(" where t1.name like '%" + s_dormManager.getName() + "%'");
} else if (StringUtil.isNotEmpty(s_dormManager.getUserName())) {
sb.append(" where t1.userName like '%" + s_dormManager.getUserName() + "%'");
}
if (pageBean != null) {
sb.append(" limit " + pageBean.getStart() + "," + pageBean.getPageSize());
}
PreparedStatement pstmt = con.prepareStatement(sb.toString());
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormManager dormManager = new DormManager();
dormManager.setDormManagerId(rs.getInt("dormManId"));
int dormBuildId = rs.getInt("dormBuildId");
dormManager.setDormBuildId(dormBuildId);
dormManager.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
dormManager.setName(rs.getString("name"));
dormManager.setSex(rs.getString("sex"));
dormManager.setUserName(rs.getString("userName"));
dormManager.setTel(rs.getString("tel"));
dormManager.setPassword(rs.getString("password"));
dormManagerList.add(dormManager);
}
return dormManagerList;
}
public int dormManagerCount(Connection con, DormManager s_dormManager) throws Exception {
StringBuffer sb = new StringBuffer("select count(*) as total from t_dormManager t1");
if (StringUtil.isNotEmpty(s_dormManager.getName())) {
sb.append(" where t1.name like '%" + s_dormManager.getName() + "%'");
} else if (StringUtil.isNotEmpty(s_dormManager.getUserName())) {
sb.append(" where t1.userName like '%" + s_dormManager.getUserName() + "%'");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getInt("total");
} else {
return 0;
}
}
public DormManager dormManagerShow(Connection con, String dormManagerId) throws Exception {
String sql = "select * from t_dormManager t1 where t1.dormManId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormManagerId);
ResultSet rs = pstmt.executeQuery();
DormManager dormManager = new DormManager();
if (rs.next()) {
dormManager.setDormManagerId(rs.getInt("dormManId"));
dormManager.setDormBuildId(rs.getInt("dormBuildId"));
dormManager.setName(rs.getString("name"));
dormManager.setSex(rs.getString("sex"));
dormManager.setUserName(rs.getString("userName"));
dormManager.setTel(rs.getString("tel"));
dormManager.setPassword(rs.getString("password"));
}
return dormManager;
}
public int dormManagerAdd(Connection con, DormManager dormManager) throws Exception {
String sql = "insert into t_dormManager values(null,?,?,null,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormManager.getUserName());
pstmt.setString(2, dormManager.getPassword());
pstmt.setString(3, dormManager.getName());
pstmt.setString(4, dormManager.getSex());
pstmt.setString(5, dormManager.getTel());
return pstmt.executeUpdate();
}
public int dormManagerDelete(Connection con, String dormManagerId) throws Exception {
String sql = "delete from t_dormManager where dormManId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormManagerId);
return pstmt.executeUpdate();
}
public int dormManagerUpdate(Connection con, DormManager dormManager) throws Exception {
String sql = "update t_dormManager set userName=?,password=?,name=?,sex=?,tel=? where dormManId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormManager.getUserName());
pstmt.setString(2, dormManager.getPassword());
pstmt.setString(3, dormManager.getName());
pstmt.setString(4, dormManager.getSex());
pstmt.setString(5, dormManager.getTel());
pstmt.setInt(6, dormManager.getDormManagerId());
return pstmt.executeUpdate();
}
public boolean haveManagerByUser(Connection con, String userName) throws Exception {
String sql = "select * from t_dormmanager t1 where t1.userName=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, userName);
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return true;
}
return false;
}
}
package com.lero.dao;
import com.lero.model.DormBuild;
import com.lero.model.Record;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class RecordDao {
public List recordList(Connection con, Record s_record) throws Exception {
List recordList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_record t1");
if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {
sb.append(" and t1.studentNumber like '%" + s_record.getStudentNumber() + "%'");
} else if (StringUtil.isNotEmpty(s_record.getStudentName())) {
sb.append(" and t1.studentName like '%" + s_record.getStudentName() + "%'");
}
if (s_record.getDormBuildId() != 0) {
sb.append(" and t1.dormBuildId=" + s_record.getDormBuildId());
}
if (StringUtil.isNotEmpty(s_record.getDate())) {
sb.append(" and t1.date=" + s_record.getDate());
}
if (StringUtil.isNotEmpty(s_record.getStartDate())) {
sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
}
if (StringUtil.isNotEmpty(s_record.getEndDate())) {
sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Record record = new Record();
record.setRecordId(rs.getInt("recordId"));
record.setStudentNumber(rs.getString("studentNumber"));
record.setStudentName(rs.getString("studentName"));
int dormBuildId = rs.getInt("dormBuildId");
record.setDormBuildId(dormBuildId);
record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
record.setDormName(rs.getString("dormName"));
record.setDate(rs.getString("date"));
record.setDetail(rs.getString("detail"));
recordList.add(record);
}
return recordList;
}
public List recordListWithBuild(Connection con, Record s_record, int buildId) throws Exception {
List recordList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_record t1");
if (StringUtil.isNotEmpty(s_record.getStudentNumber())) {
sb.append(" and t1.studentNumber like '%" + s_record.getStudentNumber() + "%'");
} else if (StringUtil.isNotEmpty(s_record.getStudentName())) {
sb.append(" and t1.studentName like '%" + s_record.getStudentName() + "%'");
}
sb.append(" and t1.dormBuildId=" + buildId);
if (StringUtil.isNotEmpty(s_record.getStartDate())) {
sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
}
if (StringUtil.isNotEmpty(s_record.getEndDate())) {
sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Record record = new Record();
record.setRecordId(rs.getInt("recordId"));
record.setStudentNumber(rs.getString("studentNumber"));
record.setStudentName(rs.getString("studentName"));
int dormBuildId = rs.getInt("dormBuildId");
record.setDormBuildId(dormBuildId);
record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
record.setDormName(rs.getString("dormName"));
record.setDate(rs.getString("date"));
record.setDetail(rs.getString("detail"));
recordList.add(record);
}
return recordList;
}
public List recordListWithNumber(Connection con, Record s_record, String studentNumber) throws Exception {
List recordList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_record t1");
if (StringUtil.isNotEmpty(studentNumber)) {
sb.append(" and t1.studentNumber =" + studentNumber);
}
if (StringUtil.isNotEmpty(s_record.getStartDate())) {
sb.append(" and TO_DAYS(t1.date)>=TO_DAYS('" + s_record.getStartDate() + "')");
}
if (StringUtil.isNotEmpty(s_record.getEndDate())) {
sb.append(" and TO_DAYS(t1.date)<=TO_DAYS('" + s_record.getEndDate() + "')");
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Record record = new Record();
record.setRecordId(rs.getInt("recordId"));
record.setStudentNumber(rs.getString("studentNumber"));
record.setStudentName(rs.getString("studentName"));
int dormBuildId = rs.getInt("dormBuildId");
record.setDormBuildId(dormBuildId);
record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
record.setDormName(rs.getString("dormName"));
record.setDate(rs.getString("date"));
record.setDetail(rs.getString("detail"));
recordList.add(record);
}
return recordList;
}
public List dormBuildList(Connection con) throws Exception {
List dormBuildList = new ArrayList();
String sql = "select * from t_dormBuild";
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormBuild dormBuild = new DormBuild();
dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
dormBuild.setDormBuildName(rs.getString("dormBuildName"));
dormBuild.setDetail(rs.getString("dormBuildDetail"));
dormBuildList.add(dormBuild);
}
return dormBuildList;
}
//
// public int studentCount(Connection con, Student s_student)throws Exception {
// StringBuffer sb = new StringBuffer("select count(*) as total from t_student t1");
// if(StringUtil.isNotEmpty(s_student.getName())) {
// sb.append(" and t1.name like '%"+s_student.getName()+"%'");
// } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {
// sb.append(" and t1.stuNum like '%"+s_student.getStuNumber()+"%'");
// } else if(StringUtil.isNotEmpty(s_student.getDormName())) {
// sb.append(" and t1.dormName like '%"+s_student.getDormName()+"%'");
// }
// if(s_student.getDormBuildId()!=0) {
// sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());
// }
// PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
// ResultSet rs = pstmt.executeQuery();
// if(rs.next()) {
// return rs.getInt("total");
// } else {
// return 0;
// }
// }
public Record recordShow(Connection con, String recordId) throws Exception {
String sql = "select * from t_record t1 where t1.recordId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, recordId);
ResultSet rs = pstmt.executeQuery();
Record record = new Record();
if (rs.next()) {
record.setRecordId(rs.getInt("recordId"));
record.setStudentNumber(rs.getString("studentNumber"));
record.setStudentName(rs.getString("studentName"));
int dormBuildId = rs.getInt("dormBuildId");
record.setDormBuildId(dormBuildId);
record.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
record.setDormName(rs.getString("dormName"));
record.setDate(rs.getString("date"));
record.setDetail(rs.getString("detail"));
}
return record;
}
public int recordAdd(Connection con, Record record) throws Exception {
String sql = "insert into t_record values(null,?,?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, record.getStudentNumber());
pstmt.setString(2, record.getStudentName());
pstmt.setInt(3, record.getDormBuildId());
pstmt.setString(4, record.getDormName());
pstmt.setString(5, record.getDate());
pstmt.setString(6, record.getDetail());
return pstmt.executeUpdate();
}
public int recordDelete(Connection con, String recordId) throws Exception {
String sql = "delete from t_record where recordId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, recordId);
return pstmt.executeUpdate();
}
public int recordUpdate(Connection con, Record record) throws Exception {
String sql = "update t_record set studentNumber=?,studentName=?,dormBuildId=?,dormName=?,detail=? where recordId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, record.getStudentNumber());
pstmt.setString(2, record.getStudentName());
pstmt.setInt(3, record.getDormBuildId());
pstmt.setString(4, record.getDormName());
pstmt.setString(5, record.getDetail());
pstmt.setInt(6, record.getRecordId());
return pstmt.executeUpdate();
}
}
package com.lero.dao;
import com.lero.model.DormBuild;
import com.lero.model.Student;
import com.lero.util.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class StudentDao {
// public List studentList(Connection con, PageBean pageBean, Student s_student)throws Exception {
// List studentList = new ArrayList();
// StringBuffer sb = new StringBuffer("select * from t_student t1");
// if(StringUtil.isNotEmpty(s_student.getName())) {
// sb.append(" and t1.name like '%"+s_student.getName()+"%'");
// } else if(StringUtil.isNotEmpty(s_student.getStuNumber())) {
// sb.append(" and t1.stuNum like '%"+s_student.getStuNumber()+"%'");
// } else if(StringUtil.isNotEmpty(s_student.getDormName())) {
// sb.append(" and t1.dormName like '%"+s_student.getDormName()+"%'");
// }
// if(s_student.getDormBuildId()!=0) {
// sb.append(" and t1.dormBuildId="+s_student.getDormBuildId());
// }
// if(pageBean != null) {
// sb.append(" limit "+pageBean.getStart()+","+pageBean.getPageSize());
// }
// PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
// ResultSet rs = pstmt.executeQuery();
// while(rs.next()) {
// Student student=new Student();
// student.setStudentId(rs.getInt("studentId"));
// int dormBuildId = rs.getInt("dormBuildId");
// student.setDormBuildId(dormBuildId);
// student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
// student.setDormName(rs.getString("dormName"));
// student.setName(rs.getString("name"));
// student.setSex(rs.getString("sex"));
// student.setStuNumber(rs.getString("stuNum"));
// student.setTel(rs.getString("tel"));
// student.setPassword(rs.getString("password"));
// studentList.add(student);
// }
// return studentList;
// }
public static Student getNameById(Connection con, String studentNumber, int dormBuildId) throws Exception {
String sql = "select * from t_student t1 where t1.stuNum=? and t1.dormBuildId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, studentNumber);
pstmt.setInt(2, dormBuildId);
ResultSet rs = pstmt.executeQuery();
Student student = new Student();
if (rs.next()) {
student.setName(rs.getString("name"));
student.setDormBuildId(rs.getInt("dormBuildId"));
student.setDormName(rs.getString("dormName"));
}
return student;
}
public List studentList(Connection con, Student s_student) throws Exception {
List studentList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_student t1");
if (StringUtil.isNotEmpty(s_student.getName())) {
sb.append(" and t1.name like '%" + s_student.getName() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getDormName())) {
sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
}
if (s_student.getDormBuildId() != 0) {
sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Student student = new Student();
student.setStudentId(rs.getInt("studentId"));
int dormBuildId = rs.getInt("dormBuildId");
student.setDormBuildId(dormBuildId);
student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
student.setDormName(rs.getString("dormName"));
student.setName(rs.getString("name"));
student.setSex(rs.getString("sex"));
student.setStuNumber(rs.getString("stuNum"));
student.setTel(rs.getString("tel"));
student.setPassword(rs.getString("password"));
studentList.add(student);
}
return studentList;
}
public boolean haveNameByNumber(Connection con, String studentNumber) throws Exception {
String sql = "select * from t_student t1 where t1.stuNum=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, studentNumber);
ResultSet rs = pstmt.executeQuery();
Student student = new Student();
if (rs.next()) {
student.setName(rs.getString("name"));
student.setDormBuildId(rs.getInt("dormBuildId"));
student.setDormName(rs.getString("dormName"));
return true;
}
return false;
}
public List studentListWithBuild(Connection con, Student s_student, int buildId) throws Exception {
List studentList = new ArrayList();
StringBuffer sb = new StringBuffer("select * from t_student t1");
if (StringUtil.isNotEmpty(s_student.getName())) {
sb.append(" and t1.name like '%" + s_student.getName() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getDormName())) {
sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
}
sb.append(" and t1.dormBuildId=" + buildId);
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
Student student = new Student();
student.setStudentId(rs.getInt("studentId"));
int dormBuildId = rs.getInt("dormBuildId");
student.setDormBuildId(dormBuildId);
student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
student.setDormName(rs.getString("dormName"));
student.setName(rs.getString("name"));
student.setSex(rs.getString("sex"));
student.setStuNumber(rs.getString("stuNum"));
student.setTel(rs.getString("tel"));
student.setPassword(rs.getString("password"));
studentList.add(student);
}
return studentList;
}
public List dormBuildList(Connection con) throws Exception {
List dormBuildList = new ArrayList();
String sql = "select * from t_dormBuild";
PreparedStatement pstmt = con.prepareStatement(sql);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
DormBuild dormBuild = new DormBuild();
dormBuild.setDormBuildId(rs.getInt("dormBuildId"));
dormBuild.setDormBuildName(rs.getString("dormBuildName"));
dormBuild.setDetail(rs.getString("dormBuildDetail"));
dormBuildList.add(dormBuild);
}
return dormBuildList;
}
public int studentCount(Connection con, Student s_student) throws Exception {
StringBuffer sb = new StringBuffer("select count(*) as total from t_student t1");
if (StringUtil.isNotEmpty(s_student.getName())) {
sb.append(" and t1.name like '%" + s_student.getName() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getStuNumber())) {
sb.append(" and t1.stuNum like '%" + s_student.getStuNumber() + "%'");
} else if (StringUtil.isNotEmpty(s_student.getDormName())) {
sb.append(" and t1.dormName like '%" + s_student.getDormName() + "%'");
}
if (s_student.getDormBuildId() != 0) {
sb.append(" and t1.dormBuildId=" + s_student.getDormBuildId());
}
PreparedStatement pstmt = con.prepareStatement(sb.toString().replaceFirst("and", "where"));
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
return rs.getInt("total");
} else {
return 0;
}
}
public Student studentShow(Connection con, String studentId) throws Exception {
String sql = "select * from t_student t1 where t1.studentId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, studentId);
ResultSet rs = pstmt.executeQuery();
Student student = new Student();
if (rs.next()) {
student.setStudentId(rs.getInt("studentId"));
int dormBuildId = rs.getInt("dormBuildId");
student.setDormBuildId(dormBuildId);
student.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
student.setDormName(rs.getString("dormName"));
student.setName(rs.getString("name"));
student.setSex(rs.getString("sex"));
student.setStuNumber(rs.getString("stuNum"));
student.setTel(rs.getString("tel"));
student.setPassword(rs.getString("password"));
}
return student;
}
public int studentAdd(Connection con, Student student) throws Exception {
String sql = "insert into t_student values(null,?,?,?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, student.getStuNumber());
pstmt.setString(2, student.getPassword());
pstmt.setString(3, student.getName());
pstmt.setInt(4, student.getDormBuildId());
pstmt.setString(5, student.getDormName());
pstmt.setString(6, student.getSex());
pstmt.setString(7, student.getTel());
return pstmt.executeUpdate();
}
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();
}
public int studentUpdate(Connection con, Student student) throws Exception {
String sql = "update t_student set stuNum=?,password=?,name=?,dormBuildId=?,dormName=?,sex=?,tel=? where studentId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, student.getStuNumber());
pstmt.setString(2, student.getPassword());
pstmt.setString(3, student.getName());
pstmt.setInt(4, student.getDormBuildId());
pstmt.setString(5, student.getDormName());
pstmt.setString(6, student.getSex());
pstmt.setString(7, student.getTel());
pstmt.setInt(8, student.getStudentId());
return pstmt.executeUpdate();
}
}
package com.lero.dao;
import com.lero.model.Admin;
import com.lero.model.DormManager;
import com.lero.model.Student;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
public class UserDao {
public Admin Login(Connection con, Admin admin) throws Exception {
Admin resultAdmin = null;
String sql = "select * from t_admin where userName=? and password=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, admin.getUserName());
pstmt.setString(2, admin.getPassword());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
resultAdmin = new Admin();
resultAdmin.setAdminId(rs.getInt("adminId"));
resultAdmin.setUserName(rs.getString("userName"));
resultAdmin.setPassword(rs.getString("password"));
resultAdmin.setName(rs.getString("name"));
resultAdmin.setSex(rs.getString("sex"));
resultAdmin.setTel(rs.getString("tel"));
}
return resultAdmin;
}
public DormManager Login(Connection con, DormManager dormManager) throws Exception {
DormManager resultDormManager = null;
String sql = "select * from t_dormmanager where userName=? and password=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, dormManager.getUserName());
pstmt.setString(2, dormManager.getPassword());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
resultDormManager = new DormManager();
resultDormManager.setDormManagerId(rs.getInt("dormManId"));
resultDormManager.setUserName(rs.getString("userName"));
resultDormManager.setPassword(rs.getString("password"));
resultDormManager.setDormBuildId(rs.getInt("dormBuildId"));
resultDormManager.setName(rs.getString("name"));
resultDormManager.setSex(rs.getString("sex"));
resultDormManager.setTel(rs.getString("tel"));
}
return resultDormManager;
}
public Student Login(Connection con, Student student) throws Exception {
Student resultStudent = null;
String sql = "select * from t_student where stuNum=? and password=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, student.getStuNumber());
pstmt.setString(2, student.getPassword());
ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
resultStudent = new Student();
resultStudent.setStudentId(rs.getInt("studentId"));
resultStudent.setStuNumber(rs.getString("stuNum"));
resultStudent.setPassword(rs.getString("password"));
int dormBuildId = rs.getInt("dormBuildId");
resultStudent.setDormBuildId(dormBuildId);
resultStudent.setDormBuildName(DormBuildDao.dormBuildName(con, dormBuildId));
resultStudent.setDormName(rs.getString("dormName"));
resultStudent.setName(rs.getString("name"));
resultStudent.setSex(rs.getString("sex"));
resultStudent.setTel(rs.getString("tel"));
}
return resultStudent;
}
public int adminUpdate(Connection con, int adminId, String password) throws Exception {
String sql = "update t_admin set password=? where adminId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, password);
pstmt.setInt(2, adminId);
return pstmt.executeUpdate();
}
public int managerUpdate(Connection con, int managerId, String password) throws Exception {
String sql = "update t_dormmanager set password=? where dormManId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, password);
pstmt.setInt(2, managerId);
return pstmt.executeUpdate();
}
public int studentUpdate(Connection con, int studentId, String password) throws Exception {
String sql = "update t_student set password=? where studentId=?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, password);
pstmt.setInt(2, studentId);
return pstmt.executeUpdate();
}
}
package com.lero.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class PropertiesUtil {
public static String getValue(String key) {
Properties prop = new Properties();
InputStream in = new PropertiesUtil().getClass().getResourceAsStream("/dorm.properties");
try {
prop.load(in);
} catch (IOException e) {
e.printStackTrace();
}
return (String) prop.get(key);
}
}
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
<%@ page import="com.lero.model.Admin" %>
<%@ page import="com.lero.model.DormManager" %>
<%@ page import="com.lero.model.Student" %>
<%
if (request.getAttribute("user") == null) {
String userName = null;
String password = null;
String userType = null;
String remember = null;
Cookie[] cookies = request.getCookies();
for (int i = 0; cookies != null && i < cookies.length; i++) {
if (cookies[i].getName().equals("dormuser")) {
userName = cookies[i].getValue().split("-")[0];
password = cookies[i].getValue().split("-")[1];
userType = cookies[i].getValue().split("-")[2];
remember = cookies[i].getValue().split("-")[3];
}
}
if (userName == null) {
userName = "";
}
if (password == null) {
password = "";
}
if (userType == null) {
userType = "";
} else if ("admin".equals(userType)) {
pageContext.setAttribute("user", new Admin(userName, password));
pageContext.setAttribute("userType", 1);
} else if ("dormManager".equals(userType)) {
pageContext.setAttribute("user", new DormManager(userName, password));
pageContext.setAttribute("userType", 2);
} else if ("student".equals(userType)) {
pageContext.setAttribute("user", new Student(userName, password));
pageContext.setAttribute("userType", 3);
}
if ("yes".equals(remember)) {
pageContext.setAttribute("remember", 1);
}
}
%>
宿舍管理系统登录
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
宿舍管理系统
宿舍管理系统
当前用户: ${currentUser.userName }
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
宿舍管理系统
宿舍管理系统
当前用户: ${currentUser.userName }
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8" %>
宿舍管理系统
宿舍管理系统
当前用户: ${currentUser.userName }
Java+JSP实现学生图书管理系统
Java+JSP实现学生信息管理系统
Java+JSP实现用户信息管理系统
Java+Servlet+JSP实现航空订票系统
Java+Servlet+JSP实现新闻发布系统
Java+Servlet+JSP实现学生信息管理系统
Java+Servlet+JSP实现学生选课管理系统
Java+Servlet+JSP实现学生成绩管理系统-1
Java+Servlet+JSP实现学生成绩管理系统-2
Java+Servlet+JSP实现宠物诊所管理系统
Java+SSM+JSP实现网上考试系统
Java+SSH+JSP实现在线考试系统
Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统
Java+Swing实现斗地主游戏
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存储数据
点击以下链接获取源码,数据库文件在sql文件下面。
Java+Servlet+JSP+Bootstrap+Mysql学生宿舍管理系统源码
请点击以下链接,部署你的项目。
IDEA如何导入JavaWeb项目超详细视频教程
如有侵权请联系我删除。
如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!想要获取其他资源可关注左侧微信公众号获取!