The classroom environment is JDK1.8 reservation system, mysql8.0 version of the system is mainly to complete the classroom reservation, which at the time of booking room, we need to fill in the classroom, make an appointment to the start date and end date, if the classroom exists and the period of free then you can make an appointment success, if the import my database, There is a default administrator account, its account and password are root, the administrator is mainly responsible for adding and deleting functions to the classroom, source code and database are on Github

Here is github source code and database github.com/uphe/classr…

A network backup link: pan.baidu.com/s/14boqsgHw… Extraction code: APRL

The following is an introduction to each package of the system. First, the package of model layer is described. The content under the package corresponds to the user table and classroom table in our database

Then there is our DAO layer package, which completes our data add, delete, change and check operations

Then there is our util package, which does the connecting and closing of the database and the processing of strings and numbers

Then there is our User package, which does the linking of the user login to the data at the time of registration

Then, when our room package is completed, we will make corresponding responses through background data when we conduct add, delete, change and check operations

Finally is our Web, here is mainly to complete the page display and human-computer interaction

The results are shown below, starting with the login page

Then there’s the registration page

Then there is the administrator page

Finally, there is the user page, where a reservation is made for room 520

The class_room_system.sql data is given here

-- MySQL dump 10.13 Distrib 8.0.17, for Win64 (x86_64)
--
-- Host: localhost Database: class_room_system
-- ------------------------------------------------------
- Server version 8.0.17

/ *! 40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/ *! 40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/ *! 40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/ *! 50503 SET NAMES utf8mb4 */;
/ *! 40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/ *! 40103 SET TIME_ZONE='+00:00' */;
/ *! 40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/ *! 40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/ *! 40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/ *! 40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `room`
--

DROP TABLE IF EXISTS `room`;
/ *! 40101 SET @saved_cs_client = @@character_set_client */;
/ *! 50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `room` (
  `roomID` int(255) NOT NULL AUTO_INCREMENT COMMENT 'Increment of Classroom Number',
  `roomName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `roomEven` varchar(255) DEFAULT NULL COMMENT 'Reasons for applying',
  `roomStart` bigint(255) DEFAULT NULL COMMENT 'Start time for Classroom application',
  `roomEnd` bigint(255) DEFAULT NULL COMMENT 'End time for Classroom application'.PRIMARY KEY (`roomID`)
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=utf8;
/ *! 40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `room`
--

LOCK TABLES `room` WRITE;
/ *! 40000 ALTER TABLE `room` DISABLE KEYS */;
INSERT INTO `room` VALUES (52.'1314'.NULL.0.0), (53.'520'.NULL.0.0);
/ *! 40000 ALTER TABLE `room` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `user`
--

DROP TABLE IF EXISTS `user`;
/ *! 40101 SET @saved_cs_client = @@character_set_client */;
/ *! 50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `user` (
  `userID` int(10) NOT NULL AUTO_INCREMENT COMMENT 'user id',
  `userName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'Username',
  `userPwd` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 'User password',
  `userPower` int(255) NOT NULL COMMENT 'User rights'.PRIMARY KEY (`userID`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
/ *! 40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `user`
--

LOCK TABLES `user` WRITE;
/ *! 40000 ALTER TABLE `user` DISABLE KEYS */;
INSERT INTO `user` VALUES (1.'root'.'root'.0), (2.'123'.'123'.1);
/ *! 40000 ALTER TABLE `user` ENABLE KEYS */;
UNLOCK TABLES;
/ *! 40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/ *! 40101 SET SQL_MODE=@OLD_SQL_MODE */;
/ *! 40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/ *! 40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/ *! 40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/ *! 40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/ *! 40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/ *! 40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-11-28 18:51:37
Copy the code

There are two Javabeans

package com.model;

public class User {
    private int userID;
    private  String userName;
    private String userPwd;
    private int userPower;

    public int getUserID(a) {
        return userID;
    }

    public void setUserID(int userID) {
        this.userID = userID;
    }

    public String getUserName(a) {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPwd(a) {
        return userPwd;
    }

    public void setUserPwd(String userPwd) {
        this.userPwd = userPwd;
    }

    public int getUserPower(a) {
        return userPower;
    }

    public void setUserPower(int userPower) {
        this.userPower = userPower; }}Copy the code

 

package com.model;

public class Room {
    private int roomID;
    private String roomName;
    private String roomEven;
    private long roomStart;
    private long roomEnd;



    public int getRoomID(a) {
        return roomID;
    }

    public void setRoomID(int roomID) {
        this.roomID = roomID;
    }

    public String getRoomName(a) {
        return roomName;
    }

    public void setRoomName(String roomName) {
        this.roomName = roomName;
    }

    public String getRoomEven(a) {
        return roomEven;
    }

    public void setRoomEven(String roomEven) {
        this.roomEven = roomEven;
    }

    public long getRoomStart(a) {
        return roomStart;
    }

    public void setRoomStart(long roomStart) {
        this.roomStart = roomStart;
    }

    public long getRoomEnd(a) {
        return roomEnd;
    }

    public void setRoomEnd(long roomEnd) {
        this.roomEnd = roomEnd; }}Copy the code

Here is a brief introduction to room’S Dao implementation, which includes CRUD functions

package com.dao;

import com.util.CloseUtil;
import com.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class RoomInsert {
    public int insert(String roomName,String message,long startTime,long endTime) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        try {
            conn = dbUtil.getConn();
            String sql = "insert into room values(null,? ,? ,? ,?) ";
            PreparedStatement pst = (PreparedStatement) conn.prepareStatement(sql);
            pst.setString(1, roomName);
            pst.setString(2, message);
            pst.setLong(3, startTime);
            pst.setLong(4, endTime);
            return pst.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            new CloseUtil().close(conn);
        }
        return 0; }}Copy the code
package com.dao;

import com.util.CloseUtil;
import com.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class RoomDelete {
    public int delete(String roomName) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        try {
            conn = dbUtil.getConn();
            String sql = "delete from room where roomName=?";
            PreparedStatement pst = (PreparedStatement) conn.prepareStatement(sql);
            pst.setString(1, roomName);
            return pst.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            new CloseUtil().close(conn);
        }
        return 0;
    }

    public int deleteNull(String roomName) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        try {
            conn = dbUtil.getConn();
            String sql = "delete from room where roomStart=0 and roomName=? ";
            PreparedStatement pst = (PreparedStatement) conn.prepareStatement(sql);
            pst.setString(1, roomName);
            return pst.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            new CloseUtil().close(conn);
        }
        return 0; }}Copy the code
package com.dao;

import com.util.CloseUtil;
import com.util.DbUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class RoomUpdate {
    public int update(String roomName,long startTime) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        try {
            conn = dbUtil.getConn();

            String sql = "update room set roomEven = null,roomStart = 0 , roomEnd = 0 where roomName = ? and roomStart = ?";
            PreparedStatement pst = (PreparedStatement) conn.prepareStatement(sql);
            pst.setString(1, roomName);
            pst.setLong(2, startTime);
            return pst.executeUpdate();
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            new CloseUtil().close(conn);
        }
        return 0; }}Copy the code
package com.dao;

import com.model.Room;
import com.model.User;
import com.util.CloseUtil;
import com.util.DbUtil;
import com.util.StringUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class RoomSelect {
    public List<Room> selectRoomName(String roomName) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        User user = null;
        List<Room> list = new ArrayList<>();
        try {
            conn = dbUtil.getConn();
            // Create an Sql command
            String sql = "select * from room where roomName = ?";
            // Create an Sql command object
            ps = conn.prepareStatement(sql);
            // Assign a placeholder value
            ps.setString(1,roomName);
            rs = ps.executeQuery();
            while (rs.next()) {
                Room room = new Room();
                room.setRoomID(rs.getInt("roomID"));
                room.setRoomName(rs.getString("RoomName"));
                room.setRoomEven(rs.getString("roomEven"));
                room.setRoomStart(rs.getLong("roomStart"));
                room.setRoomEnd(rs.getLong("roomEnd")); list.add(room); }}catch (Exception e) {
            e.printStackTrace();
        } finally {
            new CloseUtil().close(conn);
        }
        return list;
    }


    public List<Room> selectAll(a) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        User user = null;
        List<Room> list = new ArrayList<>();
        try {
            conn = dbUtil.getConn();
            // Create an Sql command
            String sql = "select * from room";
            // Create an Sql command object
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                Room room = new Room();
                room.setRoomID(rs.getInt("roomID"));
                room.setRoomName(rs.getString("RoomName"));
                room.setRoomEven(rs.getString("roomEven"));
                room.setRoomStart(rs.getLong("roomStart"));
                room.setRoomEnd(rs.getLong("roomEnd")); list.add(room); }}catch (Exception e) {
            e.printStackTrace();
        } finally {
            new CloseUtil().close(conn);
        }
        return list;
    }

    public List<Room> selectNull(a) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        User user = null;
        List<Room> list = new ArrayList<>();
        try {
            conn = dbUtil.getConn();
            // Create an Sql command
            String sql = "select * from room where roomStart = 0 and roomEnd = 0;";
            // Create an Sql command object
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                Room room = new Room();
                room.setRoomID(rs.getInt("roomID"));
                room.setRoomName(rs.getString("RoomName"));
                room.setRoomEven(rs.getString("roomEven"));
                room.setRoomStart(rs.getLong("roomStart"));
                room.setRoomEnd(rs.getLong("roomEnd")); list.add(room); }}catch (Exception e) {
            e.printStackTrace();
        } finally {
            new CloseUtil().close(conn);
        }
        return list;
    }

    public List<Room> selectNotNull(a) {
        DbUtil dbUtil = new DbUtil();
        Connection conn = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        User user = null;
        List<Room> list = new ArrayList<>();
        try {
            conn = dbUtil.getConn();
            // Create an Sql command
            String sql = "select * from room where roomStart ! = 0 and roomEnd ! = 0;";
            // Create an Sql command object
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            while (rs.next()) {
                Room room = new Room();
                room.setRoomID(rs.getInt("roomID"));
                room.setRoomName(rs.getString("RoomName"));
                room.setRoomEven(rs.getString("roomEven"));
                room.setRoomStart(rs.getLong("roomStart"));
                room.setRoomEnd(rs.getLong("roomEnd")); list.add(room); }}catch (Exception e) {
            e.printStackTrace();
        } finally {
            new CloseUtil().close(conn);
        }
        returnlist; }}Copy the code

In the page display use is JSP, here gives a login home page JSP

<%@ page contentType="text/html; charset=UTF-8" language="java"%> < HTML > <head> <title> Login page </title> <link rel="stylesheet" href="mainStyle.css" type="text/css" media="all" />
</head>
<body>
<div class="container"> < H1 > Classroom management system </h1> <divclass="signIn">
        <form action="login" method="post">
            <input type="text" class="userName" name="userName" placeholder="Account"  />
            <input type="password" class="userPwd pass" name="userPwd"  placeholder="Password"  /><br>
            <input type="submit" name="login" value="Login" />
            <input type="submit" name="register" value="Registered" />
        </form>
    </div>
</div>
</body>
</html>
Copy the code