├── .classpath ├── .project ├── .settings ├── .jsdtscope ├── org.eclipse.jdt.core.prefs ├── org.eclipse.wst.common.component ├── org.eclipse.wst.common.project.facet.core.xml ├── org.eclipse.wst.jsdt.ui.superType.container └── org.eclipse.wst.jsdt.ui.superType.name ├── README.md ├── WebContent ├── AddBook.jsp ├── AddReader.jsp ├── AllBookInfo.jsp ├── BookSeek.jsp ├── H_top.jsp ├── LendBooks.jsp ├── LibraryInfo.jsp ├── META-INF │ └── MANIFEST.MF ├── M_HomePage.jsp ├── M_navigation.jsp ├── R_HomePage.jsp ├── R_navigation.jsp ├── ReaderInfo.jsp ├── ReaderSeek.jsp ├── WEB-INF │ ├── BookInfo.jsp │ └── lib │ │ ├── jsp-api.jar │ │ ├── jstl-1.2.jar │ │ ├── mysql-connector-java-5.1.7-bin.jar │ │ ├── servlet-api.jar │ │ └── standard.jar ├── booksort.jsp ├── index.jsp ├── removeBook.jsp ├── remveReader.jsp ├── returnBook.jsp └── updateReaderInfo.jsp ├── build └── classes │ ├── SaveServlet │ ├── AddBookServlet.class │ ├── AddReaderServlet.class │ ├── AllBookInfo.class │ ├── BookInfoServlet.class │ ├── BookSortInfoServlet.class │ ├── LendBookServlet.class │ ├── LoginServlet.class │ ├── ReaderInfoServlet.class │ ├── SeekReaderInfoServlet.class │ ├── addBookSortServlet.class │ ├── addBook_SortServlet.class │ ├── removeBookServlet.class │ ├── removeBookSortServlet.class │ ├── removeReaderServlet.class │ ├── returnBookServlet.class │ └── updateReaderInfoServlet.class │ └── com │ └── lyq │ └── bean │ ├── Book.class │ ├── BookSort.class │ ├── Lendbook.class │ ├── MysqlLinking.class │ └── Reader.class ├── mysql └── yu.sql └── src ├── SaveServlet ├── AddBookServlet.java ├── AddReaderServlet.java ├── AllBookInfo.java ├── BookInfoServlet.java ├── BookSortInfoServlet.java ├── LendBookServlet.java ├── LoginServlet.java ├── ReaderInfoServlet.java ├── SeekReaderInfoServlet.java ├── addBookSortServlet.java ├── addBook_SortServlet.java ├── removeBookServlet.java ├── removeBookSortServlet.java ├── removeReaderServlet.java ├── returnBookServlet.java └── updateReaderInfoServlet.java └── com └── lyq └── bean ├── Book.java ├── BookSort.java ├── Lendbook.java ├── MysqlLinking.java └── Reader.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | J_Library 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.wst.jsdt.core.javascriptValidator 10 | 11 | 12 | 13 | 14 | org.eclipse.jdt.core.javabuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.wst.common.project.facet.core.builder 20 | 21 | 22 | 23 | 24 | org.eclipse.wst.validation.validationbuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.jem.workbench.JavaEMFNature 31 | org.eclipse.wst.common.modulecore.ModuleCoreNature 32 | org.eclipse.wst.common.project.facet.core.nature 33 | org.eclipse.jdt.core.javanature 34 | org.eclipse.wst.jsdt.core.jsNature 35 | 36 | 37 | -------------------------------------------------------------------------------- /.settings/.jsdtscope: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 6 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 7 | org.eclipse.jdt.core.compiler.source=1.8 8 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.common.project.facet.core.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.container: -------------------------------------------------------------------------------- 1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary -------------------------------------------------------------------------------- /.settings/org.eclipse.wst.jsdt.ui.superType.name: -------------------------------------------------------------------------------- 1 | Window -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 图书馆管理系统 2 | 3 | **技术栈:** Servlet、MySQL 4 | 5 | **主要功能:** 6 | 7 | 1、用户管理(管理员、老师、学生) 8 | 2、图书管理 9 | 3、借阅管理 10 | 4、还书管理 11 | -------------------------------------------------------------------------------- /WebContent/AddBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | 添加图书 9 | 10 | 11 |
12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 62 | 63 |
15 |

添加图书信息

16 |
17 |
图书名称:
作者:
出版社:
出版时间:
页数:
价格:
类别: 47 | 52 |
条形码:
60 | 61 |
64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /WebContent/AddReader.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 添加读者 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 |
14 |

添加用户信息

15 |
16 |
用户名:
性别: 25 | 男  26 | 女 27 |
年龄:
班级:
学号:
类别:
电话号码:
51 | 52 |
55 |
56 | 57 | -------------------------------------------------------------------------------- /WebContent/AllBookInfo.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | Insert title here 9 | 10 | 11 | 12 | 13 | 16 | 17 |
14 |

所有图书信息

15 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
条形码图书名称作 者出 版 社出版时间页 数价 格类 别库存量
${b.getbarCode()}${b.getbName()}${b.getwriter()}${b.getpress()}${b.getpresstime()}${b.getpageNum()}${b.getprice()}${b.getsort()}${b.getBooknum()}
45 | 46 | -------------------------------------------------------------------------------- /WebContent/BookSeek.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 图书搜索 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 22 | 29 | 30 | 33 | 34 |
14 |

搜索图书

15 |
16 |
模糊查询  20 | 精确查询 21 | 23 | 28 | 31 | 32 |
35 |
36 | 37 | -------------------------------------------------------------------------------- /WebContent/H_top.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 | 11 | 12 | 15 | 16 |
13 |

河南科技学院图书馆

14 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /WebContent/LendBooks.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 借 书 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 |
14 |

借阅图书

15 |
16 |
要借图书的条形码:
24 | 25 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /WebContent/LibraryInfo.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 图书馆信息 8 | 9 | 10 |

河南科技学院图书馆

11 |

基本信息

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
中文名称河南科技学院图书馆馆舍面积3.2万
始建于1949年地址河南科技学院
21 | 22 | 23 |

简介

24 |

河南科技学院图书馆始建于1949年,历经平原省农业学校图书馆、平原农学院图书馆、 25 | 百泉农业学校图书馆、百泉农业专科学校图书馆、河南职业技术师范学院图书馆等时期, 26 | 2004年5月,随学校更名改为现名。 现设有6部2室,分别为采编部、流通部、阅览部、情 27 | 报部、现代技术部、典藏咨询部、办公室和文检教研室;图书馆现有工作人员70名,正式 28 | 职工42名,外聘人员28名。 29 |

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /WebContent/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /WebContent/M_HomePage.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 河南科技学院图书馆 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /WebContent/M_navigation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
图书馆信息 图书搜索 图书库存 管理员信息 搜索用户信息 修改用户信息 添加用户 添加图书 删除用户 删除图书 图书类别
31 | 32 | 33 | -------------------------------------------------------------------------------- /WebContent/R_HomePage.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 河南科技学院图书馆 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /WebContent/R_navigation.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
图书馆信息 图书搜索 图书库存 用户信息 修改用户信息 借阅图书 归还图书
27 | 28 | 29 | -------------------------------------------------------------------------------- /WebContent/ReaderInfo.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | Insert title here 9 | 10 | 11 |

用户信息

12 | 13 | 14 | 17 | 18 |
15 |

用户信息

16 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
类 别用户名性别年龄班级/部门学号/工号电话号码借阅数量可借数量
${r.getrSort()}${r.getrName()}${r.getrsex()}${r.getrage()}${r.getrClass()}${r.getrNo()}${r.getrPhoneNum()}${r.getLendNum()}${r.getCanLendNum()}
47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
已借图书图书条形码
${l.getLendbook()}${l.getBarCode()}
58 | 59 | 60 | -------------------------------------------------------------------------------- /WebContent/ReaderSeek.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | Insert title here 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 26 | 27 |
14 |

搜索用户信息

15 |
16 |
用户名:
24 | 25 |
28 |
29 | 30 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/BookInfo.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | Insert title here 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 |
15 | 返回上一级 16 |
20 |

搜索图书信息

21 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
条形码图书名称作 者出 版 社出版时间页 数价 格类 别借阅次数借阅状态借阅者
${b.getbarCode()}${b.getbName()}${b.getwriter()}${b.getpress()}${b.getpresstime()}${b.getpageNum()}${b.getprice()}${b.getsort()}${b.getLendNum()}${b.getstate()}${b.getBorrower()}
55 | 56 | -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/jsp-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/WebContent/WEB-INF/lib/jsp-api.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/jstl-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/WebContent/WEB-INF/lib/jstl-1.2.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/mysql-connector-java-5.1.7-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/WebContent/WEB-INF/lib/mysql-connector-java-5.1.7-bin.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/servlet-api.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/WebContent/WEB-INF/lib/servlet-api.jar -------------------------------------------------------------------------------- /WebContent/WEB-INF/lib/standard.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/WebContent/WEB-INF/lib/standard.jar -------------------------------------------------------------------------------- /WebContent/booksort.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | Insert title here 9 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
图书所有类型${bs2.getBooksort()}
30 |
31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 |
添加图书类别
39 | 40 |
43 |
44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 55 |
删除图书类别
52 | 53 |
56 |
57 | 58 | -------------------------------------------------------------------------------- /WebContent/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 登录页面 8 | 9 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 50 |
用户类别: 33 | 37 |
用户名:
密    码:
  49 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /WebContent/removeBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 删除图书 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 |
14 |

删除图书

15 |
16 |
图书名称:
条形码:
28 | 29 |
32 |
33 | 34 | -------------------------------------------------------------------------------- /WebContent/remveReader.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 删除用户 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 30 | 31 |
14 |

删除用户

15 |
16 |
用户名:
学号/工号:
28 | 29 |
32 |
33 | 34 | -------------------------------------------------------------------------------- /WebContent/returnBook.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | 4 | 5 | 6 | 7 | 还 书 8 | 9 | 10 |
11 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 |
14 |

归还图书

15 |
16 |
要还的图书的条形码:
25 | 26 |
29 |
30 | 31 | -------------------------------------------------------------------------------- /WebContent/updateReaderInfo.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" 2 | pageEncoding="UTF-8"%> 3 | <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4 | 5 | 6 | 7 | 8 | Insert title here 9 | 10 | 11 |
12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 60 | 61 |
15 |

修改用户信息

16 |
17 |
用户名:
学号/工号:
类别:
性别: 34 | 男  35 | 女 36 |
新密码:
年龄:
班级:
电话号码:
58 | 59 |
62 |
63 | 64 | -------------------------------------------------------------------------------- /build/classes/SaveServlet/AddBookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/AddBookServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/AddReaderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/AddReaderServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/AllBookInfo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/AllBookInfo.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/BookInfoServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/BookInfoServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/BookSortInfoServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/BookSortInfoServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/LendBookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/LendBookServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/LoginServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/LoginServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/ReaderInfoServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/ReaderInfoServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/SeekReaderInfoServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/SeekReaderInfoServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/addBookSortServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/addBookSortServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/addBook_SortServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/addBook_SortServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/removeBookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/removeBookServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/removeBookSortServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/removeBookSortServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/removeReaderServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/removeReaderServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/returnBookServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/returnBookServlet.class -------------------------------------------------------------------------------- /build/classes/SaveServlet/updateReaderInfoServlet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/SaveServlet/updateReaderInfoServlet.class -------------------------------------------------------------------------------- /build/classes/com/lyq/bean/Book.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/com/lyq/bean/Book.class -------------------------------------------------------------------------------- /build/classes/com/lyq/bean/BookSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/com/lyq/bean/BookSort.class -------------------------------------------------------------------------------- /build/classes/com/lyq/bean/Lendbook.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/com/lyq/bean/Lendbook.class -------------------------------------------------------------------------------- /build/classes/com/lyq/bean/MysqlLinking.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/com/lyq/bean/MysqlLinking.class -------------------------------------------------------------------------------- /build/classes/com/lyq/bean/Reader.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaoxiangyu/LibraryManage/d3176348aa043f4ed953bf9aecb5b5b4b4469943/build/classes/com/lyq/bean/Reader.class -------------------------------------------------------------------------------- /mysql/yu.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : library 5 | Source Server Version : 50548 6 | Source Host : localhost:3306 7 | Source Database : yu 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50548 11 | File Encoding : 65001 12 | 13 | Date: 2016-05-18 17:31:45 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for books 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `books`; 22 | CREATE TABLE `books` ( 23 | `barCode` varchar(255) NOT NULL, 24 | `bName` varchar(255) DEFAULT NULL, 25 | `writer` varchar(255) DEFAULT NULL, 26 | `press` varchar(255) DEFAULT NULL, 27 | `presstime` varchar(255) DEFAULT NULL, 28 | `price` decimal(10,0) DEFAULT NULL, 29 | `sort` varchar(255) DEFAULT NULL, 30 | `pageNum` int(11) DEFAULT NULL, 31 | `LendNum` int(11) DEFAULT NULL, 32 | `state` varchar(255) DEFAULT NULL, 33 | PRIMARY KEY (`barCode`) 34 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of books 38 | -- ---------------------------- 39 | INSERT INTO `books` VALUES ('2015001', 'Java疯狂讲义', '李刚', '电子工程出版社', '2008-09-01', '109', '计算机', '877', '1', '已借'); 40 | INSERT INTO `books` VALUES ('2015002', '王文兴文集', '王文兴', '北京科学出版社', '2007-12-01', '120', '文学', '430', '1', '未借'); 41 | INSERT INTO `books` VALUES ('2015003', 'C语言', '谭浩强', '清华大学出版社', '2016-04-12', '50', '计算机', '500', '3', '已借'); 42 | INSERT INTO `books` VALUES ('2015006', '大学物理', '赵近芳', '北京邮电大学', '2014-11-01', '36', '物理', '292', '1', '已借'); 43 | INSERT INTO `books` VALUES ('2015007', '大学英语', '康璐璐', '清华电视出版社', '2012-02-01', '65', '英语', '454', '1', '已借'); 44 | INSERT INTO `books` VALUES ('2015008', 'Java Web开发与应用', '郭克华', '清华大学出版社', '2012-04-01', '45', '计算机', '435', '0', '未借'); 45 | INSERT INTO `books` VALUES ('2343545', 'fcd', 'fff', 'refr', '1012', '423', '文学', '324', '0', '未借'); 46 | INSERT INTO `books` VALUES ('5646', 'gv', 'gvf', 'gvf', 'vgd', '54', '文学', '55', '0', '未借'); 47 | 48 | -- ---------------------------- 49 | -- Table structure for booksort 50 | -- ---------------------------- 51 | DROP TABLE IF EXISTS `booksort`; 52 | CREATE TABLE `booksort` ( 53 | `id` int(11) NOT NULL AUTO_INCREMENT, 54 | `bSort` varchar(255) NOT NULL, 55 | PRIMARY KEY (`id`) 56 | ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; 57 | 58 | -- ---------------------------- 59 | -- Records of booksort 60 | -- ---------------------------- 61 | INSERT INTO `booksort` VALUES ('1', '文学'); 62 | INSERT INTO `booksort` VALUES ('2', '物理'); 63 | INSERT INTO `booksort` VALUES ('3', '英语'); 64 | INSERT INTO `booksort` VALUES ('4', '计算机'); 65 | INSERT INTO `booksort` VALUES ('5', '机械'); 66 | 67 | -- ---------------------------- 68 | -- Table structure for lendbooks 69 | -- ---------------------------- 70 | DROP TABLE IF EXISTS `lendbooks`; 71 | CREATE TABLE `lendbooks` ( 72 | `id` int(2) NOT NULL AUTO_INCREMENT, 73 | `rNo` varchar(255) DEFAULT NULL, 74 | `lendbook` varchar(255) DEFAULT NULL, 75 | PRIMARY KEY (`id`) 76 | ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; 77 | 78 | -- ---------------------------- 79 | -- Records of lendbooks 80 | -- ---------------------------- 81 | INSERT INTO `lendbooks` VALUES ('2', '201501001', 'Java疯狂讲义'); 82 | INSERT INTO `lendbooks` VALUES ('4', '201501004', '大学物理'); 83 | INSERT INTO `lendbooks` VALUES ('6', '201501003', '大学英语'); 84 | INSERT INTO `lendbooks` VALUES ('10', '201501004', 'C语言'); 85 | 86 | -- ---------------------------- 87 | -- Table structure for reader 88 | -- ---------------------------- 89 | DROP TABLE IF EXISTS `reader`; 90 | CREATE TABLE `reader` ( 91 | `rNo` varchar(255) NOT NULL, 92 | `rName` varchar(255) DEFAULT NULL, 93 | `rsex` varchar(255) DEFAULT NULL, 94 | `rage` int(11) DEFAULT NULL, 95 | `rClass` varchar(255) DEFAULT NULL, 96 | `rSort` varchar(255) DEFAULT NULL, 97 | `rPhoneNum` varchar(255) DEFAULT NULL, 98 | `password` varchar(255) DEFAULT NULL, 99 | `lendNum` int(2) DEFAULT NULL, 100 | `canLendNum` int(2) DEFAULT NULL, 101 | PRIMARY KEY (`rNo`) 102 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 103 | 104 | -- ---------------------------- 105 | -- Records of reader 106 | -- ---------------------------- 107 | INSERT INTO `reader` VALUES ('201501001', '钱静', '女', '19', '计科151', '学生', '14322556546', '123456', '1', '9'); 108 | INSERT INTO `reader` VALUES ('201501002', '刘韵', '女', '18', '会计152', '学生', '14543565667', '123456', '0', '10'); 109 | INSERT INTO `reader` VALUES ('201501003', '周武', '男', '19', '计科153', '学生', '14546546575', '123456', '1', '9'); 110 | INSERT INTO `reader` VALUES ('201501004', '王怡', '女', '19', '会计151', '学生', '17637453733', '654321', '2', '8'); 111 | INSERT INTO `reader` VALUES ('201501005', '焦祥宇', '男', '18', '计科151', '管理员', '18273656665', '654321', '0', '10'); 112 | INSERT INTO `reader` VALUES ('345435', 'rfg', '女', '34', 'fref', 'rfgr', '43536547', '123456', '0', '10'); 113 | INSERT INTO `reader` VALUES ('435234', 'tgg', '女', '4', 'vgf', 'fg', '54654657', '123456', '0', '10'); 114 | INSERT INTO `reader` VALUES ('fcdg', 'rfc', '女', '34', 'fd', '435', '3454365', '123456', '0', '10'); 115 | -------------------------------------------------------------------------------- /src/SaveServlet/AddBookServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.*; 6 | import javax.servlet.ServletConfig; 7 | import javax.servlet.ServletException; 8 | import javax.servlet.annotation.WebServlet; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import com.lyq.bean.MysqlLinking; 14 | 15 | @WebServlet(name = "AddBookServlet",urlPatterns ="/AddBookServlet")//注释 16 | public class AddBookServlet extends HttpServlet { 17 | private Connection conn=null; 18 | private static final long serialVersionUID = 1L; 19 | 20 | public void init(ServletConfig config) throws ServletException { 21 | (new MysqlLinking()).getLink();//连接数据库 22 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 23 | } 24 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 25 | response.setContentType("text/html"); 26 | request.setCharacterEncoding("UTF-8"); 27 | response.setCharacterEncoding("UTF-8"); 28 | String bName = request.getParameter("bName");//获取表单中属性值 29 | String writer = request.getParameter("writer"); 30 | String press = request.getParameter("press"); 31 | String presstime = request.getParameter("presstime"); 32 | String price = request.getParameter("price"); 33 | String pageNum = request.getParameter("pageNum"); 34 | String sort = request.getParameter("sort"); 35 | String barCode = request.getParameter("barCode"); 36 | if (conn != null) { 37 | try { 38 | //插入注册信息的SQL语句(使用?占位符) //添加图书属性 39 | String sql="insert into books(bName,writer,press,presstime,price,pageNum,sort,barCode,LendNum,state,borrower) values(?,?,?,?,?,?,?,?,?,?,?)"; 40 | //创建PreparedStatement对象 41 | PreparedStatement ps = conn.prepareStatement(sql); 42 | //对SQL语句中的参数动态赋值 43 | ps.setString(1,bName); 44 | ps.setString(2,writer); 45 | ps.setString(3,press); 46 | ps.setString(4,presstime); 47 | ps.setDouble(5,Double.valueOf(price)); 48 | ps.setInt(6,Integer.valueOf(pageNum)); 49 | ps.setString(7,sort); 50 | ps.setString(8,barCode); 51 | ps.setInt(9,0); 52 | ps.setString(10,"未借"); 53 | ps.setString(11,""); 54 | //执行更新操作 55 | ps.executeUpdate(); 56 | //获取PrintWriter对象 57 | PrintWriter out = response.getWriter(); 58 | //输出注册结果信息 59 | out.println(""); 64 | out.flush(); 65 | out.close(); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | } else { 70 | //发送数据库连接错误提示信息 71 | response.sendError(500, "数据库连接错误!"); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/SaveServlet/AddReaderServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import com.lyq.bean.MysqlLinking; 16 | 17 | @WebServlet(name = "AddReaderServlet",urlPatterns ="/AddReaderServlet")//注释 18 | public class AddReaderServlet extends HttpServlet { 19 | private static final long serialVersionUID = 1L; 20 | private Connection conn=null; 21 | 22 | public void init(ServletConfig config) throws ServletException { 23 | (new MysqlLinking()).getLink();//连接数据库 24 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 25 | } 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 27 | // TODO Auto-generated method stub 28 | //获取表单中属性值 29 | response.setContentType("text/html"); 30 | request.setCharacterEncoding("UTF-8"); 31 | response.setCharacterEncoding("UTF-8"); 32 | String rName = request.getParameter("rName");//获取表单属性 33 | String rsex = request.getParameter("rsex"); 34 | String rage = request.getParameter("rage"); 35 | String rClass = request.getParameter("rClass"); 36 | String rSort = request.getParameter("rSort"); 37 | String rNo = request.getParameter("rNo"); 38 | String rPhoneNum = request.getParameter("rPhoneNum"); 39 | if (conn != null) { 40 | try { 41 | //插入注册信息的SQL语句(使用?占位符) //添加读者信息 42 | String sql="insert into reader(rNo,rName,rsex,rage,rClass,rSort,rPhoneNum,password,lendNum,canLendNum) values(?,?,?,?,?,?,?,?,?,?)"; 43 | //创建PreparedStatement对象 44 | PreparedStatement ps = conn.prepareStatement(sql); 45 | //对SQL语句中的参数动态赋值 46 | ps.setString(1,rNo); 47 | ps.setString(2,rName); 48 | ps.setString(3,rsex); 49 | ps.setInt(4,Integer.valueOf(rage)); 50 | ps.setString(5,rClass); 51 | ps.setString(6,rSort); 52 | ps.setString(7,rPhoneNum); 53 | ps.setString(8,"123456"); 54 | ps.setInt(9, 0); 55 | ps.setInt(10, 10); 56 | //执行更新操作 57 | ps.executeUpdate(); 58 | //获取PrintWriter对象 59 | PrintWriter out = response.getWriter();//输出结果信息 60 | out.println(""); 65 | out.flush(); 66 | out.close(); 67 | } catch (Exception e) { 68 | e.printStackTrace(); 69 | } 70 | } else { 71 | //发送数据库连接错误提示信息 72 | response.sendError(500, "数据库连接错误!"); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/SaveServlet/AllBookInfo.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletConfig; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import com.lyq.bean.Book; 18 | import com.lyq.bean.MysqlLinking; 19 | 20 | @WebServlet(name= "AllBookInfo" , urlPatterns="/AllBookInfo")//注释 21 | public class AllBookInfo extends HttpServlet { 22 | private Connection conn=null; 23 | private static final long serialVersionUID = 1L; 24 | 25 | public void init(ServletConfig config) throws ServletException { 26 | (new MysqlLinking()).getLink();//连接数据库 27 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 28 | } 29 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 30 | response.setContentType("text/html"); 31 | request.setCharacterEncoding("UTF-8"); 32 | response.setCharacterEncoding("UTF-8"); 33 | List list=new ArrayList<>(); 34 | if (conn != null) { 35 | try { 36 | String sql="select * from books "; //查询所有图书 37 | //创建PreparedStatement对象 38 | PreparedStatement ps = conn.prepareStatement(sql); 39 | ResultSet rs=ps.executeQuery(); 40 | 41 | while(rs.next()){ //遍历数据库内所有图书信息 42 | Book b=new Book();//创建book对象 43 | 44 | String bookname=rs.getString("bName"); 45 | String sql2="select num from booknum where bName=?"; //查询图书库存 46 | PreparedStatement ps2 = conn.prepareStatement(sql2); 47 | ps2.setString(1, bookname); 48 | ResultSet rs2=ps2.executeQuery(); 49 | int booknum=0; 50 | while(rs2.next()){ 51 | booknum=rs2.getInt("num"); 52 | } 53 | 54 | b.setbName(rs.getString("bName")); 55 | b.setwriter(rs.getString("writer")); 56 | b.setpress(rs.getString("press")); 57 | b.setpresstime(rs.getString("presstime")); 58 | b.setbarCode(rs.getString("barCode")); 59 | b.setsort(rs.getString("sort")); 60 | b.setstate(rs.getString("state")); 61 | b.setprice(rs.getDouble("price")); 62 | b.setpageNum(rs.getInt("pageNum")); 63 | b.setBooknum(booknum); 64 | //b.setLendNum(rs.getInt("LendNum")); 65 | list.add(b);//把book对象b放在list集合中 66 | } 67 | /*for(int i=0;i list=new ArrayList<>(); 51 | if (conn != null) { 52 | try { 53 | String sql=""; 54 | PreparedStatement ps=null; 55 | if(seek.equals("模糊查询")){ 56 | sql="select * from books where "+select+" like '%"+name+"%'" ; 57 | ps = conn.prepareStatement(sql); 58 | } 59 | else if(seek.equals("精确查询")){ 60 | sql="select * from books where "+select+"=?"; //根据select的属性值查询图书 61 | //创建PreparedStatement对象 62 | ps = conn.prepareStatement(sql); 63 | ps.setString(1, name); 64 | } 65 | 66 | 67 | ResultSet rs=ps.executeQuery(); 68 | 69 | while(rs.next()){ //遍历所有图书把符合条件的图书对象存入list集合 70 | Book b=new Book(); 71 | b.setbName(rs.getString("bName")); 72 | b.setwriter(rs.getString("writer")); 73 | b.setpress(rs.getString("press")); 74 | b.setpresstime(rs.getString("presstime")); 75 | b.setbarCode(rs.getString("barCode")); 76 | b.setsort(rs.getString("sort")); 77 | b.setstate(rs.getString("state")); 78 | b.setprice(rs.getDouble("price")); 79 | b.setpageNum(rs.getInt("pageNum")); 80 | b.setLendNum(rs.getInt("LendNum")); 81 | b.setBorrower(rs.getString("borrower")); 82 | list.add(b); 83 | } 84 | request.setAttribute("list", list); //把list存在request对象中 85 | String bookname=""; 86 | for(Book bs:list){ 87 | bookname=bs.getbName(); 88 | } 89 | if(bookname.equals("")){//判断搜索结果是否为空 90 | PrintWriter out = response.getWriter(); 91 | //输出注册结果信息 92 | out.println(""); 97 | out.flush(); 98 | out.close(); 99 | } 100 | else{ 101 | request.getRequestDispatcher("/WEB-INF/BookInfo.jsp").forward(request, response);//转到/WEB-INF/BookInfo.jsp页面 102 | } 103 | } 104 | catch (Exception e) { 105 | e.printStackTrace(); 106 | } 107 | } 108 | else { 109 | //发送数据库连接错误提示信息 110 | response.sendError(500, "数据库连接错误!"); 111 | } 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /src/SaveServlet/BookSortInfoServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletConfig; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import com.lyq.bean.BookSort; 18 | import com.lyq.bean.MysqlLinking; 19 | 20 | @WebServlet(name="BookSortInfoServlet",urlPatterns="/BookSortInfoServlet")//注释 21 | public class BookSortInfoServlet extends HttpServlet { 22 | private Connection conn=null; 23 | private static final long serialVersionUID = 1L; 24 | public void init(ServletConfig config) throws ServletException { 25 | (new MysqlLinking()).getLink();//连接数据库 26 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 27 | } 28 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 29 | response.setContentType("text/html"); 30 | request.setCharacterEncoding("UTF-8"); 31 | response.setCharacterEncoding("UTF-8"); 32 | List bslist2=new ArrayList<>(); 33 | if (conn != null) { 34 | try { 35 | String sql="select * from booksort ";//查询所有图书类型 36 | //创建PreparedStatement对象 37 | PreparedStatement ps = conn.prepareStatement(sql); 38 | ResultSet rs=ps.executeQuery(); 39 | while(rs.next()){//把所有图书类型存放在list集合中 40 | BookSort bs=new BookSort(); 41 | bs.setBooksort((rs.getString("bSort"))); 42 | bslist2.add(bs); 43 | } 44 | request.setAttribute("bslist2", bslist2);//储存bslist2集合 45 | request.getRequestDispatcher("/booksort.jsp").forward(request, response);//转换页面 46 | } 47 | catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | else { 52 | //发送数据库连接错误提示信息 53 | response.sendError(500, "数据库连接错误!"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/SaveServlet/LendBookServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | 9 | import javax.servlet.ServletConfig; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.annotation.WebServlet; 12 | import javax.servlet.http.HttpServlet; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import javax.servlet.http.HttpSession; 16 | 17 | import com.lyq.bean.MysqlLinking; 18 | 19 | @WebServlet(name = "LendBookServlet",urlPatterns ="/LendBookServlet")//注释 20 | public class LendBookServlet extends HttpServlet { 21 | private Connection conn=null; 22 | private static final long serialVersionUID = 1L; 23 | public void init(ServletConfig config) throws ServletException { 24 | (new MysqlLinking()).getLink();//连接数据库 25 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 26 | } 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | HttpSession session = request.getSession();//创建Session对象 32 | String rno = (String) session.getAttribute("RNO");//从Session对象中获得用户学号/工号 33 | String name = (String) session.getAttribute("NAME"); 34 | String barCode = request.getParameter("barCode"); //获得要借的的图书名 35 | String nowState="",bookName="";//定义图书借阅状态、书名和借阅数量变量 36 | int LendNums=0; 37 | if (conn != null) { 38 | try { 39 | String selectSql="select * from books where barCode=?"; 40 | PreparedStatement ps0 = conn.prepareStatement(selectSql); 41 | ps0.setString(1, barCode); 42 | ResultSet rs=ps0.executeQuery(); 43 | while(rs.next()){ 44 | nowState=rs.getString("state");//获得图书借阅状态和借阅数量 45 | LendNums=rs.getInt("LendNum"); 46 | bookName=rs.getString("bName"); 47 | } 48 | 49 | int booknum=0;//定义该图书的库存的数量 50 | String selectSql_2="select * from booknum where bName=?"; 51 | PreparedStatement ps_2 = conn.prepareStatement(selectSql_2); 52 | ps_2.setString(1, bookName); 53 | ResultSet rs_2=ps_2.executeQuery(); 54 | while(rs_2.next()){ 55 | booknum=rs_2.getInt("num");//获得该图书的库存的数量 56 | 57 | } 58 | 59 | int num=0;//定义户借阅数量变量 60 | if(nowState.equals("未借")){//判断图书是否已被借 61 | String selectSql02="select * from reader where rNo=?"; 62 | PreparedStatement ps02 = conn.prepareStatement(selectSql02); 63 | ps02.setString(1, rno); 64 | ResultSet rs02=ps02.executeQuery(); 65 | while(rs02.next()){ 66 | num=rs02.getInt("lendNum");//获得用户借阅数量 67 | 68 | } 69 | if(num<=10){//判断用户数量是否达到上限 70 | String insertSql="insert into lendbooks(rNo,borrower,lendbook,barCode) values (?,?,?,?)"; 71 | //创建PreparedStatement对象 72 | PreparedStatement ps1 = conn.prepareStatement(insertSql); 73 | ps1.setString(1, rno); //借阅图书 74 | ps1.setString(2,name); 75 | ps1.setString(3,bookName); 76 | ps1.setString(4,barCode); 77 | ps1.executeUpdate(); 78 | 79 | String updateSql2="update reader set lendNum=?,canLendNum=? where rNo=?"; 80 | //创建PreparedStatement对象 81 | PreparedStatement ps12 = conn.prepareStatement(updateSql2); 82 | int num1=num+1;//图书借阅数量+1,可借数量-1 83 | int num2=10-num1; 84 | ps12.setInt(1, num1); 85 | ps12.setInt(2, num2); 86 | ps12.setString(3, rno); 87 | ps12.executeUpdate(); 88 | 89 | String updateSql="update books set state='已借',LendNum=?,borrower=? where barCode=?"; 90 | PreparedStatement ps2 = conn.prepareStatement(updateSql); 91 | LendNums++; 92 | ps2.setInt(1, LendNums);//改变图书借阅状态和借阅数量+1 93 | ps2.setString(2, name); 94 | ps2.setString(3,barCode); 95 | ps2.executeUpdate(); 96 | 97 | String updateSql_3="update booknum set num=? where bName=?"; 98 | PreparedStatement ps_3 = conn.prepareStatement(updateSql_3); 99 | booknum=booknum-1; 100 | ps_3.setInt(1, booknum);//改变图书库存数量-1 101 | ps_3.setString(2, bookName); 102 | ps_3.executeUpdate(); 103 | 104 | PrintWriter out = response.getWriter();//输出结果信息 105 | out.println(""); 110 | out.flush(); 111 | out.close(); 112 | } 113 | else{ 114 | PrintWriter out = response.getWriter();//输出结果信息 115 | out.println(""); 120 | out.flush(); 121 | out.close(); 122 | } 123 | } 124 | else{ 125 | PrintWriter out = response.getWriter();//输出结果信息 126 | out.println(""); 131 | out.flush(); 132 | out.close(); 133 | } 134 | } 135 | catch (Exception e) { 136 | e.printStackTrace(); 137 | } 138 | } 139 | else { 140 | //发送数据库连接错误提示信息 141 | response.sendError(500, "数据库连接错误!"); 142 | } 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /src/SaveServlet/LoginServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | 9 | import javax.servlet.ServletConfig; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.annotation.WebServlet; 12 | import javax.servlet.http.HttpServlet; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import javax.servlet.http.HttpSession; 16 | 17 | import com.lyq.bean.MysqlLinking; 18 | 19 | @WebServlet(name = "LoginServlet",urlPatterns ="/LoginServlet")//注释配置文件 20 | public class LoginServlet extends HttpServlet { 21 | private Connection conn=null; 22 | private static final long serialVersionUID = 1L; 23 | 24 | public void init(ServletConfig config) throws ServletException { 25 | (new MysqlLinking()).getLink();//连接数据库 26 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 27 | } 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 29 | // TODO Auto-generated method stub 30 | //获取表单中属性值, 31 | response.setContentType("text/html"); 32 | request.setCharacterEncoding("UTF-8"); 33 | response.setCharacterEncoding("UTF-8"); 34 | String Usersort = request.getParameter("UserSort"); //获得用户登录类型、用户名、密码 35 | String username = request.getParameter("username"); 36 | String pwd = request.getParameter("pwd"); 37 | HttpSession session = request.getSession();//创建Session对象 38 | if (conn!= null) { 39 | try { 40 | String sql="select * from reader where rName=? and password=?"; 41 | //创建PreparedStatement对象 42 | PreparedStatement ps = conn.prepareStatement(sql); 43 | ps.setString(1, username); 44 | ps.setString(2, pwd); 45 | ResultSet rs=ps.executeQuery(); 46 | String Uname=""; 47 | String Pdw=""; 48 | String usersort=""; 49 | while(rs.next()){ 50 | Uname=rs.getString("rName"); //从数据库中获得用户名,密码,用户类型 51 | Pdw=rs.getString("password"); 52 | usersort=rs.getString("rSort"); 53 | 54 | String RNO=rs.getString("rNo"); //把 用户学号/工号,用户名,用户类型存在Session对象中 55 | session.setAttribute("RNO",RNO); 56 | String NAME=Uname; 57 | session.setAttribute("NAME",NAME); 58 | String RSORT=usersort; 59 | session.setAttribute("RSORT",RSORT); 60 | } 61 | if(Uname.equals(username) && Pdw.equals(pwd)){//判断用户名,登录密码是否正确 62 | if(usersort.equals(Usersort) && usersort.equals("管理员")){//用户类型为管理员时转换到/M_HomePage.jsp页面 63 | request.getRequestDispatcher("/M_HomePage.jsp").forward(request, response); 64 | } 65 | else if(usersort.equals(Usersort) && usersort.equals("学生")){//用户类型为学生时转换到/R_HomePage.jsp页面 66 | request.getRequestDispatcher("/R_HomePage.jsp").forward(request, response); 67 | } 68 | else{//如果用户类别错误 69 | PrintWriter out = response.getWriter(); 70 | out.println(""); 75 | out.flush(); 76 | out.close(); 77 | } 78 | } 79 | else{//用户名或密码错误 80 | PrintWriter out = response.getWriter(); 81 | out.println(""); 86 | out.flush(); 87 | out.close(); 88 | } 89 | } 90 | catch (Exception e) { 91 | e.printStackTrace(); 92 | } 93 | } 94 | else { 95 | //发送数据库连接错误提示信息 96 | response.sendError(500, "数据库连接错误!"); 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/SaveServlet/ReaderInfoServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletConfig; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import javax.servlet.http.HttpSession; 17 | 18 | import com.lyq.bean.Reader; 19 | import com.lyq.bean.Lendbook; 20 | import com.lyq.bean.MysqlLinking; 21 | 22 | @WebServlet(name = "ReaderInfoServlet",urlPatterns ="/ReaderInfoServlet")//注释配置文件 23 | public class ReaderInfoServlet extends HttpServlet { 24 | private Connection conn=null; 25 | private static final long serialVersionUID = 1L; 26 | 27 | public void init(ServletConfig config) throws ServletException { 28 | (new MysqlLinking()).getLink();//连接数据库 29 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 30 | } 31 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 32 | response.setContentType("text/html"); 33 | request.setCharacterEncoding("UTF-8"); 34 | response.setCharacterEncoding("UTF-8"); 35 | HttpSession session = request.getSession(); 36 | String rno = (String) session.getAttribute("RNO"); //获得用户学号/工号 37 | List list=new ArrayList<>();//创建Reader对象集合 38 | List list2=new ArrayList<>();//创建LendBook集合 39 | if (conn != null) { 40 | try { 41 | String sql="select * from reader where rNo=? "; 42 | //创建PreparedStatement对象 43 | PreparedStatement ps = conn.prepareStatement(sql); 44 | ps.setString(1, rno); 45 | ResultSet rs=ps.executeQuery(); 46 | 47 | while(rs.next()){ //获得用户信息 48 | Reader r=new Reader(); 49 | r.setrName(rs.getString("rName")); 50 | r.setrsex(rs.getString("rsex")); 51 | r.setrage(rs.getInt("rage")); 52 | r.setrClass(rs.getString("rClass")); 53 | r.setrSort(rs.getString("rSort")); 54 | r.setrPhoneNum(rs.getString("rPhoneNum")); 55 | r.setrNo(rs.getString("rNo")); 56 | r.setLendNum(rs.getInt("lendNum")); 57 | r.setCanLendNum(rs.getInt("canLendNum")); 58 | list.add(r); 59 | } 60 | 61 | String sql2="select * from lendbooks where rNo=? "; //获得用户借阅的图书 62 | //创建PreparedStatement对象 63 | PreparedStatement ps2 = conn.prepareStatement(sql2); 64 | ps2.setString(1, rno); 65 | ResultSet rs2=ps2.executeQuery(); 66 | while(rs2.next()){ 67 | Lendbook l=new Lendbook(); 68 | l.setLendbook(rs2.getString("lendbook")); 69 | l.setBarCode(rs2.getString("barCode")); 70 | list2.add(l); 71 | } 72 | request.setAttribute("list", list); //把 用户信息储存在request对象中 73 | request.setAttribute("list2", list2); 74 | request.getRequestDispatcher("/ReaderInfo.jsp").forward(request, response);//转换到/ReaderInfo.jsp页面 75 | } 76 | catch (Exception e) { 77 | e.printStackTrace(); 78 | } 79 | } 80 | else { 81 | //发送数据库连接错误提示信息 82 | response.sendError(500, "数据库连接错误!"); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/SaveServlet/SeekReaderInfoServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletConfig; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import com.lyq.bean.Lendbook; 18 | import com.lyq.bean.MysqlLinking; 19 | import com.lyq.bean.Reader; 20 | 21 | @WebServlet(name="SeekReaderInfoServlet",urlPatterns="/SeekReaderInfoServlet") 22 | public class SeekReaderInfoServlet extends HttpServlet { 23 | private Connection conn=null; 24 | private static final long serialVersionUID = 1L; 25 | 26 | public void init(ServletConfig config) throws ServletException { 27 | (new MysqlLinking()).getLink();//连接数据库 28 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 29 | } 30 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | response.setContentType("text/html"); 32 | request.setCharacterEncoding("UTF-8"); 33 | response.setCharacterEncoding("UTF-8"); 34 | String rname = request.getParameter("seekName");//获得用户名 35 | List list=new ArrayList<>();//创建Reader对象集合 36 | List list2=new ArrayList<>();//创建LendBook集合 37 | if (conn != null) { 38 | try { 39 | String sql="select * from reader where rName=? "; 40 | //创建PreparedStatement对象 41 | PreparedStatement ps = conn.prepareStatement(sql); 42 | ps.setString(1, rname); 43 | ResultSet rs=ps.executeQuery(); 44 | 45 | while(rs.next()){ //获得用户信息 46 | Reader r=new Reader(); 47 | r.setrName(rs.getString("rName")); 48 | r.setrsex(rs.getString("rsex")); 49 | r.setrage(rs.getInt("rage")); 50 | r.setrClass(rs.getString("rClass")); 51 | r.setrSort(rs.getString("rSort")); 52 | r.setrPhoneNum(rs.getString("rPhoneNum")); 53 | r.setrNo(rs.getString("rNo")); 54 | r.setLendNum(rs.getInt("lendNum")); 55 | r.setCanLendNum(rs.getInt("canLendNum")); 56 | list.add(r); 57 | } 58 | 59 | String sql2="select * from lendbooks where borrower=? "; //获得用户借阅的图书 60 | //创建PreparedStatement对象 61 | PreparedStatement ps2 = conn.prepareStatement(sql2); 62 | ps2.setString(1, rname); 63 | ResultSet rs2=ps2.executeQuery(); 64 | while(rs2.next()){ 65 | Lendbook l=new Lendbook(); 66 | l.setLendbook(rs2.getString("lendbook")); 67 | l.setBarCode(rs2.getString("barCode")); 68 | list2.add(l); 69 | } 70 | request.setAttribute("list", list); //把 用户信息储存在request对象中 71 | request.setAttribute("list2", list2); 72 | request.getRequestDispatcher("/ReaderInfo.jsp").forward(request, response);//转换到/ReaderInfo.jsp页面 73 | } 74 | catch (Exception e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | else { 79 | //发送数据库连接错误提示信息 80 | response.sendError(500, "数据库连接错误!"); 81 | } 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /src/SaveServlet/addBookSortServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import com.lyq.bean.MysqlLinking; 16 | 17 | @WebServlet(name="addBookSortServlet",urlPatterns="/addBookSortServlet")//注释 18 | public class addBookSortServlet extends HttpServlet { 19 | private Connection conn=null; 20 | private static final long serialVersionUID = 1L; 21 | 22 | public void init(ServletConfig config) throws ServletException { 23 | (new MysqlLinking()).getLink();//连接数据库 24 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 25 | } 26 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 27 | if (conn != null) { 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | String bt=request.getParameter("bsort");//获得表单属性图书类型 32 | try { 33 | String sql="insert into booksort(bSort) values(?)"; //添加图书类型 34 | PreparedStatement ps = conn.prepareStatement(sql); 35 | ps.setString(1, bt); 36 | ps.executeUpdate(); 37 | //获取PrintWriter对象 38 | PrintWriter out = response.getWriter(); 39 | //输出注册结果信息 40 | out.println(""); 45 | out.flush(); 46 | out.close(); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } else { 51 | //发送数据库连接错误提示信息 52 | response.sendError(500, "数据库连接错误!"); 53 | } 54 | } 55 | 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/SaveServlet/addBook_SortServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.sql.Connection; 5 | import java.sql.PreparedStatement; 6 | import java.sql.ResultSet; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | import javax.servlet.ServletConfig; 11 | import javax.servlet.ServletException; 12 | import javax.servlet.annotation.WebServlet; 13 | import javax.servlet.http.HttpServlet; 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | 17 | import com.lyq.bean.BookSort; 18 | import com.lyq.bean.MysqlLinking; 19 | 20 | @WebServlet(name="addBook_SortServlet",urlPatterns="/addBook_SortServlet")//注释 21 | public class addBook_SortServlet extends HttpServlet { 22 | private Connection conn=null; 23 | private static final long serialVersionUID = 1L; 24 | public void init(ServletConfig config) throws ServletException { 25 | (new MysqlLinking()).getLink();//连接数据库 26 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 27 | } 28 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 29 | response.setContentType("text/html"); 30 | request.setCharacterEncoding("UTF-8"); 31 | response.setCharacterEncoding("UTF-8"); 32 | List bslist=new ArrayList<>(); 33 | if (conn != null) { 34 | try { 35 | String sql="select * from booksort "; //获得图书类型,在图书类型下拉菜单中输出 36 | PreparedStatement ps = conn.prepareStatement(sql); //创建PreparedStatement对象 37 | ResultSet rs=ps.executeQuery(); 38 | while(rs.next()){ 39 | BookSort bs=new BookSort(); 40 | bs.setBooksort((rs.getString("bSort"))); 41 | bslist.add(bs);//把保存图书类型在bslist集合中 42 | } 43 | 44 | request.setAttribute("bslist", bslist); //把bslist存放在request对象中 45 | request.getRequestDispatcher("/AddBook.jsp").forward(request, response);//转到AddBook.jsp页面 46 | } 47 | catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | else { 52 | //发送数据库连接错误提示信息 53 | response.sendError(500, "数据库连接错误!"); 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/SaveServlet/removeBookServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import com.lyq.bean.MysqlLinking; 16 | 17 | @WebServlet(name = "removeBookServlet",urlPatterns ="/removeBookServlet")//配置文件 18 | public class removeBookServlet extends HttpServlet { 19 | private Connection conn=null; 20 | private static final long serialVersionUID = 1L; 21 | public void init(ServletConfig config) throws ServletException { 22 | (new MysqlLinking()).getLink();//连接数据库 23 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 24 | } 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 | // TODO Auto-generated method stub 27 | //获取表单中属性值 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | String rmbookName = request.getParameter("rmbookName"); //获得删除图书名称和条形码 32 | String barCode = request.getParameter("barCode"); 33 | if (conn != null) { 34 | try { 35 | String sql="delete from books where bName=? and barCode=?;"; //删除图书 36 | //创建PreparedStatement对象 37 | PreparedStatement ps = conn.prepareStatement(sql); 38 | ps.setString(1, rmbookName); 39 | ps.setString(2,barCode); 40 | ps.executeUpdate(); 41 | PrintWriter out = response.getWriter(); 42 | //输出注册结果信息 43 | out.println(""); 48 | out.flush(); 49 | out.close(); 50 | } 51 | catch (Exception e) { 52 | e.printStackTrace(); 53 | } 54 | } 55 | else { 56 | //发送数据库连接错误提示信息 57 | response.sendError(500, "数据库连接错误!"); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/SaveServlet/removeBookSortServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import com.lyq.bean.MysqlLinking; 16 | 17 | @WebServlet(name="removeBookSortServlet", urlPatterns="/removeBookSortServlet")//配置文件 18 | public class removeBookSortServlet extends HttpServlet { 19 | private Connection conn=null; 20 | private static final long serialVersionUID = 1L; 21 | public void init(ServletConfig config) throws ServletException { 22 | (new MysqlLinking()).getLink();//连接数据库 23 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 24 | } 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 | // TODO Auto-generated method stub 27 | //获取表单中属性值 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | String rmbsort = request.getParameter("bsort2");//获得删除图书类别 32 | if (conn != null) { 33 | try { 34 | String sql="delete from booksort where bSort=?"; //删除图书类别 35 | //创建PreparedStatement对象 36 | PreparedStatement ps = conn.prepareStatement(sql); 37 | ps.setString(1, rmbsort); 38 | ps.executeUpdate(); 39 | PrintWriter out = response.getWriter(); 40 | //输出注册结果信息 41 | out.println(""); 46 | out.flush(); 47 | out.close(); 48 | } 49 | catch (Exception e) { 50 | e.printStackTrace(); 51 | } 52 | } 53 | else { 54 | //发送数据库连接错误提示信息 55 | response.sendError(500, "数据库连接错误!"); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/SaveServlet/removeReaderServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | 15 | import com.lyq.bean.MysqlLinking; 16 | 17 | @WebServlet(name = "removeReaderServlet",urlPatterns ="/removeReaderServlet")//配置文件 18 | public class removeReaderServlet extends HttpServlet { 19 | private Connection conn=null; 20 | private static final long serialVersionUID = 1L; 21 | public void init(ServletConfig config) throws ServletException { 22 | (new MysqlLinking()).getLink();//连接数据库 23 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 24 | } 25 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 | // TODO Auto-generated method stub 27 | //获取表单中属性值 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | String rmreaderName = request.getParameter("rmreaderName"); //获得要删除用户名和学号/工号 32 | String rno = request.getParameter("rNo"); 33 | 34 | if (conn != null) { 35 | try { 36 | String sql="delete from reader where rName=? and rNo=?;";//删除用户 37 | //创建PreparedStatement对象 38 | PreparedStatement ps = conn.prepareStatement(sql); 39 | ps.setString(1, rmreaderName); 40 | ps.setString(2,rno); 41 | ps.executeUpdate(); 42 | PrintWriter out = response.getWriter(); 43 | //输出注册结果信息 44 | out.println(""); 49 | out.flush(); 50 | out.close(); 51 | } 52 | catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | } 56 | else { 57 | //发送数据库连接错误提示信息 58 | response.sendError(500, "数据库连接错误!"); 59 | } 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/SaveServlet/returnBookServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | 9 | import javax.servlet.ServletConfig; 10 | import javax.servlet.ServletException; 11 | import javax.servlet.annotation.WebServlet; 12 | import javax.servlet.http.HttpServlet; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import javax.servlet.http.HttpSession; 16 | 17 | import com.lyq.bean.MysqlLinking; 18 | 19 | @WebServlet(name="returnBookServlet",urlPatterns="/returnBookServlet")//配置文件 20 | public class returnBookServlet extends HttpServlet { 21 | private Connection conn=null; 22 | private static final long serialVersionUID = 1L; 23 | public void init(ServletConfig config) throws ServletException { 24 | (new MysqlLinking()).getLink();//连接数据库 25 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 26 | } 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 | // TODO Auto-generated method stub 29 | //获取表单中属性值 30 | response.setContentType("text/html"); 31 | request.setCharacterEncoding("UTF-8"); 32 | response.setCharacterEncoding("UTF-8"); 33 | HttpSession session = request.getSession(); 34 | String rno = (String) session.getAttribute("RNO");//获得用户学号/工号 ,和要还的图书的条形码 35 | String returnbarCode = request.getParameter("returnbarCode"); 36 | if (conn != null) { 37 | try { 38 | 39 | int num=0; 40 | String selectSql02="select * from reader where rNo=?"; 41 | PreparedStatement ps02 = conn.prepareStatement(selectSql02); 42 | ps02.setString(1, rno); 43 | ResultSet rs02=ps02.executeQuery(); 44 | while(rs02.next()){ 45 | num=rs02.getInt("lendNum");//获得用户借阅数量 46 | 47 | } 48 | 49 | String bookName=""; 50 | String selectSql_1="select * from books where barCode=?"; 51 | PreparedStatement ps_1 = conn.prepareStatement(selectSql_1); 52 | ps_1.setString(1, returnbarCode); 53 | ResultSet rs_1=ps_1.executeQuery(); 54 | while(rs_1.next()){ 55 | bookName=rs_1.getString("bName");//获得该图书名称 56 | 57 | } 58 | 59 | 60 | int booknum=0;//定义该图书的库存的数量 61 | String selectSql_2="select * from booknum where bName=?"; 62 | PreparedStatement ps_2 = conn.prepareStatement(selectSql_2); 63 | ps_2.setString(1, bookName); 64 | ResultSet rs_2=ps_2.executeQuery(); 65 | while(rs_2.next()){ 66 | booknum=rs_2.getInt("num");//获得该图书的库存的数量 67 | 68 | } 69 | 70 | if(num>0){//判断借阅数量是否大于0 71 | String sql="delete from lendbooks where rNo=? and barCode=?;"; //归还图书 72 | //创建PreparedStatement对象 73 | PreparedStatement ps = conn.prepareStatement(sql); 74 | ps.setString(1, rno); 75 | ps.setString(2,returnbarCode); 76 | ps.executeUpdate(); 77 | 78 | 79 | String insertSql2="update reader set lendNum=?,canLendNum=? where rNo=?"; 80 | //创建PreparedStatement对象 81 | PreparedStatement ps12 = conn.prepareStatement(insertSql2); 82 | int num1=num-1; 83 | int num2=10-num1; 84 | ps12.setInt(1, num1);//更改借阅数量和可借数量 85 | ps12.setInt(2, num2); 86 | ps12.setString(3, rno); 87 | ps12.executeUpdate(); 88 | 89 | String updateSql="update books set state='未借',borrower='' where barCode=?";//更改图书借阅状态为‘未借’ 90 | PreparedStatement ps2 = conn.prepareStatement(updateSql); 91 | ps2.setString(1, returnbarCode); 92 | ps2.executeUpdate(); 93 | 94 | String updateSql_3="update booknum set num=? where bName=?";//更改图书库存 95 | PreparedStatement ps_3 = conn.prepareStatement(updateSql_3); 96 | booknum++; 97 | ps_3.setInt(1, booknum); 98 | ps_3.setString(2, bookName); 99 | ps_3.executeUpdate(); 100 | 101 | //输出结果信息 102 | PrintWriter out = response.getWriter(); 103 | out.println(""); 108 | out.flush(); 109 | out.close(); 110 | } 111 | } 112 | catch (Exception e) { 113 | e.printStackTrace(); 114 | } 115 | } 116 | else { 117 | //发送数据库连接错误提示信息 118 | response.sendError(500, "数据库连接错误!"); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/SaveServlet/updateReaderInfoServlet.java: -------------------------------------------------------------------------------- 1 | package SaveServlet; 2 | 3 | import java.io.IOException; 4 | import java.io.PrintWriter; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | 8 | import javax.servlet.ServletConfig; 9 | import javax.servlet.ServletException; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import javax.servlet.http.HttpSession; 15 | 16 | import com.lyq.bean.MysqlLinking; 17 | 18 | @WebServlet(name="updateReaderInfoServlet",urlPatterns="/updateReaderInfoServlet")//配置文件 19 | public class updateReaderInfoServlet extends HttpServlet { 20 | private Connection conn=null; 21 | private static final long serialVersionUID = 1L; 22 | 23 | public void init(ServletConfig config) throws ServletException { 24 | (new MysqlLinking()).getLink();//连接数据库 25 | conn=MysqlLinking.conn;//得到连接数据库的Connection对象conn 26 | } 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 | response.setContentType("text/html"); 29 | request.setCharacterEncoding("UTF-8"); 30 | response.setCharacterEncoding("UTF-8"); 31 | HttpSession session = request.getSession(); 32 | String rno = (String) session.getAttribute("RNO");//获得用户更改后的信息 33 | String rName =(String) session.getAttribute("NAME"); 34 | String rsex = request.getParameter("newrsex"); 35 | String rage = request.getParameter("newrage"); 36 | String rClass = request.getParameter("newrClass"); 37 | String rPhoneNum = request.getParameter("newrPhoneNum"); 38 | String password = request.getParameter("newPassword"); 39 | 40 | if (conn != null) { 41 | try { 42 | //插入注册信息的SQL语句(使用?占位符) 43 | String sql="update reader set rsex=?,rage=?,rClass=?,rPhoneNum=?,password=? where rNo=? and rName=?"; 44 | //创建PreparedStatement对象 45 | PreparedStatement ps = conn.prepareStatement(sql); 46 | //对SQL语句中的参数动态赋值 47 | ps.setString(1,rsex); 48 | ps.setInt(2,Integer.valueOf(rage)); 49 | ps.setString(3,rClass); 50 | ps.setString(4,rPhoneNum); 51 | ps.setString(5,password); 52 | ps.setString(6,rno); 53 | ps.setString(7,rName); 54 | //执行更新操作 55 | ps.executeUpdate(); 56 | //获取PrintWriter对象 57 | PrintWriter out = response.getWriter(); 58 | //输出注册结果信息 59 | out.println(""); 64 | out.flush(); 65 | out.close(); 66 | } catch (Exception e) { 67 | e.printStackTrace(); 68 | } 69 | } else { 70 | //发送数据库连接错误提示信息 71 | response.sendError(500, "数据库连接错误!"); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/com/lyq/bean/Book.java: -------------------------------------------------------------------------------- 1 | package com.lyq.bean; 2 | public class Book {//bName,writer,press,presstime,price,pageNum,sort,barCode,LendNum,state 3 | 4 | private String barCode;//图书属性变量: 条形码,作者,书名,出版社,出版时间,价格,借阅状态, 5 | private String writer; //图书类别,页数,借阅次数 6 | private String bName; 7 | private String press; 8 | private String presstime; 9 | private double price; 10 | private String state; 11 | private String sort; 12 | private int pageNum; 13 | private int LendNum; 14 | private String borrower; 15 | private int booknum; 16 | public int getBooknum() { 17 | return booknum; 18 | } 19 | public void setBooknum(int booknum) { 20 | this.booknum = booknum; 21 | } 22 | public String getBorrower() { 23 | return borrower; 24 | } 25 | public void setBorrower(String borrower) { 26 | this.borrower = borrower; 27 | } 28 | public String getstate() { 29 | return state; 30 | } 31 | public void setstate(String sta) { 32 | state=sta; 33 | } 34 | 35 | public String getsort() { 36 | return sort; 37 | } 38 | public void setsort(String sor) { 39 | sort=sor; 40 | } 41 | 42 | public String getbName() { 43 | return bName; 44 | } 45 | public void setbName(String name) { 46 | bName=name; 47 | } 48 | 49 | public String getwriter() { 50 | return writer; 51 | } 52 | public void setwriter(String wri) { 53 | writer=wri; 54 | } 55 | 56 | public String getpress() { 57 | return press; 58 | } 59 | public void setpress(String pre) { 60 | press=pre; 61 | } 62 | 63 | public String getpresstime() { 64 | return presstime; 65 | } 66 | public void setpresstime(String pretm) { 67 | presstime=pretm; 68 | } 69 | 70 | public double getprice() { 71 | return price; 72 | } 73 | public void setprice(double pri) { 74 | price=pri; 75 | } 76 | 77 | public int getpageNum() { 78 | return pageNum; 79 | } 80 | public void setpageNum(int pnu) { 81 | pageNum=pnu; 82 | } 83 | 84 | public int getLendNum() { 85 | return LendNum; 86 | } 87 | public void setLendNum(int lnu) { 88 | LendNum=lnu; 89 | } 90 | 91 | public String getbarCode() { 92 | return barCode; 93 | } 94 | public void setbarCode(String bar) { 95 | barCode=bar; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/com/lyq/bean/BookSort.java: -------------------------------------------------------------------------------- 1 | package com.lyq.bean; 2 | 3 | public class BookSort { 4 | private String booksort;//图书类别 5 | public String getBooksort() { 6 | return booksort; 7 | } 8 | 9 | public void setBooksort(String booksort) { 10 | this.booksort = booksort; 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/com/lyq/bean/Lendbook.java: -------------------------------------------------------------------------------- 1 | package com.lyq.bean; 2 | 3 | public class Lendbook { 4 | String rNo,lendbook,barCode;//用户学号/工号和图书类别 5 | 6 | public String getBarCode() { 7 | return barCode; 8 | } 9 | 10 | public void setBarCode(String barCode) { 11 | this.barCode = barCode; 12 | } 13 | 14 | public String getRno() { 15 | return rNo; 16 | } 17 | 18 | public void setRno(String rno) { 19 | rNo = rno; 20 | } 21 | 22 | public String getLendbook() { 23 | return lendbook; 24 | } 25 | 26 | public void setLendbook(String lendbook) { 27 | this.lendbook = lendbook; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/com/lyq/bean/MysqlLinking.java: -------------------------------------------------------------------------------- 1 | package com.lyq.bean; 2 | 3 | import java.sql.*; 4 | 5 | public class MysqlLinking { 6 | public static Connection conn=null; 7 | public void getLink(){ 8 | try { 9 | String driver="com.mysql.jdbc.Driver"; 10 | String url="jdbc:mysql://localhost/yu?useUnicode=true&characterEncoding=utf8"; 11 | String user="root"; 12 | String password="123456"; 13 | Class.forName(driver);//加载数据库驱动 14 | conn=DriverManager.getConnection(url,user,password);//获取数据库连接 15 | 16 | if (conn != null) { 17 | System.out.println("数据库连接成功"); 18 | } 19 | } 20 | catch (Exception e) { 21 | e.printStackTrace(); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/lyq/bean/Reader.java: -------------------------------------------------------------------------------- 1 | package com.lyq.bean; 2 | 3 | public class Reader { 4 | private String rNo; //用户属性:学号/工号,用户名,性别,年龄,班级/部门,用户类别, 5 | private String rName; //电话号码,借阅数量,可以借阅数量 6 | private String rsex; 7 | private int rage; 8 | private String rClass; 9 | private String rSort; 10 | private String rPhoneNum; 11 | private int lendNum; 12 | private int canLendNum; 13 | 14 | public int getCanLendNum() { 15 | return canLendNum; 16 | } 17 | public void setCanLendNum(int canLendNum) { 18 | this.canLendNum = canLendNum; 19 | } 20 | public int getLendNum() { 21 | return lendNum; 22 | } 23 | public void setLendNum(int lendNum) { 24 | this.lendNum = lendNum; 25 | } 26 | public String getrNo() { 27 | return rNo; 28 | } 29 | public void setrNo(String rno) { 30 | rNo=rno; 31 | } 32 | 33 | public String getrName() { 34 | return rName; 35 | } 36 | public void setrName(String rna) { 37 | rName=rna; 38 | } 39 | 40 | public String getrsex() { 41 | return rsex; 42 | } 43 | public void setrsex(String rse) { 44 | rsex=rse; 45 | } 46 | 47 | public int getrage() { 48 | return rage; 49 | } 50 | public void setrage(int rag) { 51 | rage=rag; 52 | } 53 | 54 | public String getrClass() { 55 | return rClass; 56 | } 57 | public void setrClass(String rcl) { 58 | rClass=rcl; 59 | } 60 | 61 | public String getrSort() { 62 | return rSort; 63 | } 64 | public void setrSort(String rso) { 65 | rSort=rso; 66 | } 67 | 68 | public String getrPhoneNum() { 69 | return rPhoneNum; 70 | } 71 | public void setrPhoneNum(String rpn) { 72 | rPhoneNum=rpn; 73 | } 74 | 75 | } 76 | --------------------------------------------------------------------------------