Self-service reading room based on JSP+Servlet+MySQL

Project running video: Click to view

I. System screenshots

Development environment and technical architecture

System architecture: The development of the system is the use of Java as the main programming language programming development, with the mainstream database MySQL to store data, background MVC design mode as the main technical support with JSP, CSS as a page to display Java, JavaScript to complete the logical interaction of the page, at the same time the introduction of editor plug-in UEditor, Develop a simple and practical, functional self-service reading room management system.

Development environment: JDK7+ Eclipse + Tomcat7 +mysql5.5

Iii. System functions

1. Reader Identity

Personal information management View personal information modify personal information self-help book management query book information self-help borrowing management query borrowing information self-help return management query return information self-help fine management fine information query system logout management system logout

2 Administrator Status

Password Information management Reset personal password Self-service book management New book release book update book Remove book search Reader management New personnel personnel change Remove personnel search self-service borrowing management Borrowing information management Borrowing information query self-service return management return information management Return information query self-service fine management Added penalty information Query system deregistration Management system deregistration

Download link

Click on the download

5. Project Catalog

System entity class

Public entity class

package com.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.util.Constant;
import com.util.DBO;
 

public class ComBean {

	private List list;
	private ResultSet rs = null;
	private int EVERYPAGENUM = 2;
	private int count = -1;
	private int qq = 0;
	 
	// Declare the time variable
	String date1=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
	String date=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime());
	
	// paging query
	public void setEVERYPAGENUM(int EVERYPAGENUM){
    	this.EVERYPAGENUM=EVERYPAGENUM;
    }
    public int getMessageCount(String sql) { // Get the total number of messages
       DBO dbo=new DBO();
       dbo.open();
        try { 
            rs = dbo.executeQuery(sql);
            rs.next();
            count = rs.getInt(1);
            return count;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return -1;
        } finally{ dbo.close(); }}public int getPageCount(a) { // How many pages to display (depending on how many pieces of information per page)
        if (count % EVERYPAGENUM == 0) {
            return count / EVERYPAGENUM;
        } else {
            return count / EVERYPAGENUM + 1; }}public List getMessage(int page,String sql2,int rr) { // Get the information to display on each page
        DBO dbo=new DBO();
        dbo.open();
        List list = new ArrayList();
        try {
            rs = dbo.executeQuery(sql2);
            
            System.out.println("= = = = = = = = = = = = = = = = =");
            System.out.println(sql2);
            System.out.println("= = = = = = = = = = = = = = = = =");
           
            for (int i = 0; i < (page - 1) * EVERYPAGENUM; i++) {
                rs.next();
            }
            for (int t = 0; t < EVERYPAGENUM; t++) {
                if (rs.next()) {
                    qq++;
                    List list2=new ArrayList();
                    for(int cc=1; cc<=rr; cc++){ list2.add(rs.getString(cc)); } list.add(list2); }else {
                    break; // Reduce empty loop time
                }
            }
            System.out.println("+ + + + + + + + + + + + + + + +");
            System.out.println(list);
            System.out.println("+ + + + + + + + + + + + + + + +");
            return list;
        } catch (SQLException ex) {
            ex.printStackTrace();
            return null;
        } finally{ dbo.close(); }}public int comUp(String sql){
		DBO dbo = new DBO();
		dbo.open();
		try{
			int i = dbo.executeUpdate(sql);
			if(i == 1) {return Constant.SUCCESS;
			}
			else{
				returnConstant.SYSTEM_ERROR; }}catch(Exception e){
			e.printStackTrace();
			return Constant.SYSTEM_ERROR;
		}finally{ dbo.close(); }}public List getCom(String sql,int row){ 
		DBO dbo = new DBO();
		list = new ArrayList();
		dbo.open();
		try{
			rs = dbo.executeQuery(sql);
			while(rs.next()){
				List list2 = new ArrayList();
				for(int i=1; i<=row; i++){ list2.add(rs.getString(i)); } list.add(list2); }return list;
		}catch(Exception e){
			e.printStackTrace();
			return list;
		}finally{ dbo.close(); }}public List get1Com(String sql,int row){ 
		DBO dbo = new DBO();
		list = new ArrayList();
		dbo.open();
		try{
			rs = dbo.executeQuery(sql);
			if(rs.next()){
				for(int i=1; i<=row; i++){ list.add(rs.getString(i)); }}return list;
		}catch(Exception e){
			e.printStackTrace();
			return list;
		}finally{ dbo.close(); }}public String getString(String sql){ 
		DBO dbo = new DBO();
		list = new ArrayList();
		dbo.open();
		try{
			rs = dbo.executeQuery(sql);
			if(rs.next())
			return rs.getString(1);
			else return null;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}finally{ dbo.close(); }}public int getCount(String sql){
		DBO dbo = new DBO();
		dbo.open();
		try{
			rs = dbo.executeQuery(sql);
			rs.next();
			return rs.getInt(1);
		}catch(Exception e){
			e.printStackTrace();
			return 0;
		}finally{ dbo.close(); }}public float getFloat(String sql){
		DBO dbo = new DBO();
		dbo.open();
		try{
			rs = dbo.executeQuery(sql);
			rs.next();
			return rs.getInt(1);
		}catch(Exception e){
			e.printStackTrace();
			return 0;
		}finally{ dbo.close(); }}}Copy the code

2 Database operations

package com.util;

import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.activation.DataSource;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;

public class DBO {

	private Connection conn;
	private Statement stmt;
  	private DataSource ds;
	
	public DBO(a)
	{}/** Open the database */
	public void open(a) 
	{
		try 
		{
			Class.forName("com.mysql.jdbc.Driver"); 
			conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/gxts? characterEncoding=utf-8"."root"."root"); 
			stmt=conn.createStatement();
			System.out.println("Open database connection");
		} 
		catch (Exception ex) 
		{
		System.err.println("Error opening database:"+ ex.getMessage()); }}/** Close the database and return the connection to the connection pool */
	public void close(a) 
	{
		try 
		{
		
				
		//	connMgr.freeConnection("java", conn);
			conn.close();
			System.out.println ("Release the connection");
		} 
		catch (SQLException ex) 
		{
			System.err.println("Error returning connection pool:"+ ex.getMessage()); }}/** Execute the query */
	public ResultSet executeQuery(String sql) throws SQLException
	{
		ResultSet rs = null;
		

		rs = stmt.executeQuery(sql);
		System.out.println ("Execute query");
		return rs;
	}

	/** Execute add, delete, change */
	public int executeUpdate(String sql) throws SQLException
	{
		int ret = 0;
		
	
		ret = stmt.executeUpdate(sql);
	
		System.out.println ("Implement additions, deletions and changes");
		return ret;
	}

	/** Add SQL statements to batch */
	public void addBatch(String sql) throws SQLException 
	{
		stmt.addBatch(sql);
	}

	/** Perform batch processing */
	public int [] executeBatch() throws SQLException 
	{
		boolean isAuto=conn.getAutoCommit();
		
		conn.setAutoCommit(false);
		int [] updateCounts = stmt.executeBatch();
		
// conn.commit();
		
// conn.setAutoCommit(isAuto);
		//conn.setAutoCommit(true);
		return updateCounts;
	}
	public boolean getAutoCommit(a) throws SQLException
	{
		return conn.getAutoCommit();
	}
	public void setAutoCommit(boolean auto)  throws SQLException 
	{
		conn.setAutoCommit(auto);
	}
	
	public void commit(a) throws SQLException 
	{
		conn.commit();
// this.close();
	}
	public void rollBack(a) throws SQLException 
	{
		conn.rollback();
// this.close();}}Copy the code

More information about the project can be found in JSP+Servlet+MySQL library Management system