Design and implementation of book management system

Keywords: Java JSP Database Session

Design and implementation of book management system

The structure of library staff is complex, the number of staff is limited, and it involves a wide range of aspects. If manual operation is also used to deal with the problem of book borrowing, the work will be very tedious, requiring a lot of manpower, physics, financial resources, and a great waste of resources. For the library management personnel, the library management includes the library information management, the library category management, the borrowing information management, and the administrator's letter Interest management, etc. In the past, these projects rely on manual operation and need to record these things manually. It is not only troublesome, but also often wrong, which brings a lot of inconvenience to the majority of users. Therefore, develop such a set of library management system software. It is convenient for the administrator to manage books and user information, and for the user to find books.

1. Purpose of the course design

(1) Master the basic development process of enterprise application system;
(2) Training developers to master the basic ideas and methods of application system design;
(3) Develop the ability of developers to analyze and solve problems;

2. Overview of functions to be realized by the system

(1) User login. Administrators or members log in to the system according to the user name and password for authentication.
(2) Book management. According to the book number and book name, query the basic information of the book to add, modify and delete books.
(3) Reader management. Query the basic information of the reader according to the account number and name. Add, modify and delete reader information.
(4) Book classification management. Search the book classification information according to the classification name. Add, modify and delete book classification.
(5) Book borrowing. Display all the information about the books being borrowed.
(6) Book return. Display information about all returned books.
(7) Modify and query personal information.

3. Implementation platform and technology

(1) JAVA language
(2) MYSQL database
(3) WINDOWS 10 operating system
(4) Java EE Technology
(5) Servlet Technology
(6) Eclipse tools
(7)Html,css,JavaScript

4. Demand analysis

The main purpose of the system is to realize a book management system. There are two types of users in the system: administrator and reader members. After the administrator enters the system through password authentication, the administrator can complete the functions of maintaining the system, including managing books and managing members. Reader members can query books, modify personal data, query personal borrowing information and return borrowed books. After the work is completed, they can exit the system.

5. System function module division

5.1 overall function module division of the system

5.2 user login module

After the user name and password are entered by the ordinary user, it is verified. If one of the user name and password is incorrect, it is not allowed to log in, and there is a corresponding prompt. If the user does not have an account, it can be registered on the login page. The ordinary user can query, modify and modify the password of personal data. The ordinary user can query the book information, borrow and Return. The book borrowing information and borrowing history information will be displayed on the homepage.

After the administrator enters the user name and password, verify it. If one of the user name and password is incorrect, you cannot log in, and there is a corresponding prompt. The administrator can query, modify and modify the password of personal data. The administrator can view and manage the book information, reader information and borrowing information, and classify the books

5.3 book information management module

The administrator will modify and delete the number, number, type and name of books. If ordinary users borrow books online, the total number of books will be reduced accordingly.

5.4 reader management module

The administrator can modify and delete the reader information, and can actively add new users. The module displays the number of days the user borrows, which will automatically change. The administrator can monitor the number of days the reader borrows online. If it is overdue, the account cannot be registered.

5.5 book classification management module

Administrators manage books online, add, modify and delete books.

5.6 book borrowing information module

The administrator can manage the borrowed information online and help the reader return the book actively.

5.7 book return information management module

Displays the details of the returned book.

5.8 book query module

When the user accesses the book query module, it displays the current books that can be borrowed. It has the function of querying book information by book name, and can borrow books.

5.9 book borrowing information module

Display all books borrowed by the current login user, as well as the serial number, book name, borrowing date, return date, reader account number and reader name information of each book. The login user can return the book, and there is a corresponding prompt for whether the book is returned successfully.

5.10 borrowing history module

Display the book borrowing records of the current login user.

6. Database design

6.1 E-R diagram of database

E-R diagram of admin (user) table

Book table E-R diagram

BookType table E-R diagram

History table E-R chart

6.2 database data structure design

mysql database is used in the database, and the system mainly needs to maintain 4 data tables:

User table information (admin):

book information:

Book type table information (bookType):

Book history:

7. Detailed design and implementation of the system

7.1 user login

User login is mainly to achieve authentication in the login window. The user can enter figure 5-1 by entering the user name and password to determine whether the user name exists and whether the password is correct. You can enter the main interface only after passing the system verification certificate; if the verification fails, you will jump to the login interface and return error information, such as the login account is empty, the login password is empty, the user name and password do not match, etc., and please re-enter. The librarian of this landing page is the same as the ordinary user when entering. By querying the status of the database, the librarian can judge which kind of user belongs to, so as to make different jumps.



Main code:

package com.rain.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.websocket.Session;
import com.rain.bean.AdminBean;
import com.rain.dao.AdminDao;
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public LoginServlet() {
        super();    
}
Protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
}
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //Judgment of login
        PrintWriter out = response.getWriter();
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        //Get account and password
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        AdminDao userdao = new AdminDao();
        //Judge the account and password
        boolean result = userdao.Login_verify(username, password);
        HttpSession session = request.getSession();
        //Judge whether the input is correct
        if (result) {
            AdminBean adminbean = new AdminBean();
            AdminDao admindao = new AdminDao();
            //Check the account and password to find out the reader's information
            adminbean = admindao.getAdminInfo(username, password);
            //Save aid into session
            session.setAttribute("aid", "" + adminbean.getAid());
            //Set the expiration time of the session
            session.setMaxInactiveInterval(6000);
            //Judge whether it is administrator or reader according to the value of status. status=1 is reader
            if (adminbean.getStatus() == 1) {
                response.sendRedirect("/books/index2.jsp");
            } else {
                response.sendRedirect("/books/admin.jsp");
            }
        } else {
            //No corresponding account and password found, return to login again
            session.setAttribute("state", "Password error");
            response.sendRedirect("/books/login.jsp");
        }
    }
}

7.2 book query

The administrator can inquire the book information according to the book number, book name, author name, publishing house, etc.

Main code:

package com.rain.servlet;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rain.bean.BookBean;
import com.rain.dao.BookDao;
@WebServlet("/selectServlet")
public class selectServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public selectServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        //Because there is search function in the administrator interface and reader interface, in order to return the search results to the correct page, tip is set, and tip=1 means administrator interface
        int tip = Integer.parseInt(request.getParameter("tip"));
        String name = request.getParameter("name");
        BookDao bookdao = new BookDao();
        ArrayList<BookBean> data = bookdao.getLikeList(name);
        //Store the obtained results in the request
        request.setAttribute("data", data);
        String url = "";
        //Forwarding different interfaces
        if (tip == 1) {
            url = response.encodeURL("admin_book.jsp");
        } else {
            url = response.encodeURL("select.jsp");
        }
        //Forward request
        request.getRequestDispatcher(url).forward(request, response);
    }
}

7.3 add books


Main code:

package com.rain.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rain.dao.BookDao;
@WebServlet("/AddBookServlet")
public class AddBookServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public AddBookServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //Set encoding type
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        //Get information about the book you want to add
        String card = request.getParameter("card");
        String name = request.getParameter("name");
        String type = request.getParameter("type");
        String autho = request.getParameter("autho");
        String press = request.getParameter("press");
        int num = Integer.parseInt(request.getParameter("num"));
        BookDao bookdao = new BookDao();
        //Call function, store book
        bookdao.addBook(card, name, type, autho, press, num);
        response.sendRedirect("/books/admin_book.jsp");
    }
}

7.4 book information modification


Main code:

package com.rain.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rain.dao.BookDao;
@WebServlet("/updateBookServlet")
public class updateBookServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public updateBookServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //Modify book information
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String card = request.getParameter("card");
        String name = request.getParameter("name");
        String type = request.getParameter("type");
        String autho = request.getParameter("autho");
        String press = request.getParameter("press");
        int num = Integer.parseInt(request.getParameter("num"));
        Int bid = Integer.parseInt(request.getParameter("updatebid"));
        BookDao bookdao = new BookDao();
        bookdao.updateBook(bid, card, name, type, autho, press, num);
        response.sendRedirect("/books/admin_book.jsp");
    }
}

7.5 Book deletion

Main code:

package com.rain.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rain.dao.BookDao;
@WebServlet("/deleteServlet")
public class deleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    public deleteServlet() {
        super();
        // TODO Auto-generated constructor stub
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //Delete book information
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        int bid = Integer.parseInt(request.getParameter("bid"));
        BookDao bookdao = new BookDao();
        bookdao.deleteBook(bid);
        response.sendRedirect("/books/admin_book.jsp");
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // TODO Auto-generated method stub
        doGet(request, response);
    }
}

Other modules design and implementation please check the official account number: C you again

Download complete documents and system source code:
Pay attention to official account: C you again or scan below the two-dimensional code, reply: "library management system" free access.
More dry goods waiting for you

Good use, remember to like and share!!!!
Note: this system is not my original. It is modified and innovated on the basis of the original system.
Please contact to delete the infringement

Posted by unplugme71 on Sun, 14 Jun 2020 23:18:20 -0700