/**
*
*/
package demo.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import demo.entity.Borrow;
import demo.util.DBUtil;
/**
* 对接borrow表的类
*
*/
public class BorrowDao {
/**
* 查询该借阅者当前是否有超期图书未归还
* @param readerId 借阅者id
* @return 当前有超期图书未归还:1 没有:-1
*/
public int selectNowTimeoutById(String readerId) {
Connection con = DBUtil.getConnection();
String sql = " select * from borrow where timeout=1 and time_return_real is null and id_reader = ?";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, readerId);
ResultSet rs = ps.executeQuery();
if (rs.next()) {
return 1;
}
}
catch (SQLException e) {
}
finally {
DBUtil.closeConnection(con);
}
}
return -1;
}
/**
* 归还图书时,根据num填写实际还书时间
* @param bookId
* @return 失败:-1 成功:1
*/
public int updateRealById(String bookId) {
Connection con = DBUtil.getConnection();
String sql = " update borrow set time_return_real = CURDATE() where id_book=? and time_return_real is NULL";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, bookId);
return ps.executeUpdate();
}
catch (SQLException e) {
return -1;
}
finally {
DBUtil.closeConnection(con);
}
}
return -1;
}
/**
* 续借时,修改应还时间,将应还时间修改为当前时间加一个月
* @param bookId
* @return
*/
public int updateShouldById(String bookId) {
Connection con = DBUtil.getConnection();
String sql = " update borrow set time_return_should = date_add(CURTATE(), interval 1 MONTH) where num = (SELECT a.num from(select num from borrow where id_book = ? and timeout!=1 and time_return_real is NULL) a )";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, bookId);
return ps.executeUpdate();
}
catch (SQLException e) {
return -1;
}
finally {
DBUtil.closeConnection(con);
}
}
return -1;
}
/**
* 续借次数加1
* @param bookId
* @return
*/
public int renew (String bookId) {
Connection con = DBUtil.getConnection();
String sql = " update borrow set renew = renew+1 where num = (SELECT a.num from(select num from borrow where id_book = ? and timeout!=1 and time_return_real is NULL) a )";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, bookId);
return ps.executeUpdate();
}
catch (SQLException e) {
return -1;
}
finally {
DBUtil.closeConnection(con);
}
}
return -1;
}
/**
* 返回续借次数,起始未1,续借两次后为3
* @param bookId
* @return
*/
public int returnRenewById(String bookId) {
Connection con = DBUtil.getConnection();
String sql = " SELECT renew from borrow where num = (select num from borrow where id_book = ? and timeout!=1 and time_return_real is NULL)";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, bookId);
ResultSet rs = ps.executeQuery();
int renew = 0;
if (rs.next()) {
renew = rs.getInt(1);
}
return renew;
}
catch (SQLException e) {
return 0;
}
finally {
DBUtil.closeConnection(con);
}
}
return 0;
}
/**
* 管理员当前借阅模糊查询
* @param bookId
* @param readId
* @param readerName
* @param bookName
* @return
*/
public List<Borrow> selectByOthers( String readerName, String bookName){
Connection con = DBUtil.getConnection();
String sql = "select id_book, book.name as bookname, id_reader, user.name as username, time_borrow, time_return_should from user,book,borrow where user.id=id_reader and book.id=id_book and time_return_real IS NULL and user.name like \"%\"?\"%\" and book.name like \"%\"?\"%\"";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, readerName);
ps.setString(2, bookName);
ResultSet rs = ps.executeQuery();
List<Borrow> borrowList = rsToBorrows(rs);
return borrowList;
}
catch (SQLException e) {
return null;
}
finally {
DBUtil.closeConnection(con);
}
}
return null;
}
/**
* 管理员历史借阅模糊查询
* @param bookId
* @param readId
* @param readerName
* @param bookName
* @return
*/
public List<Borrow> selectPastByOthers( String readerName, String bookName){
Connection con = DBUtil.getConnection();
String sql = "select id_book, book.name as bookname, id_reader, user.name as username, time_borrow, time_return_real from user,book,borrow where user.id=id_reader and book.id=id_book and time_return_real IS NOT NULL and user.name like \"%\"?\"%\" and book.name like \"%\"?\"%\"";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, readerName);
ps.setString(2, bookName);
ResultSet rs = ps.executeQuery();
List<Borrow> borrowList = rsToBorrows(rs);
return borrowList;
}
catch (SQLException e) {
return null;
}
finally {
DBUtil.closeConnection(con);
}
}
return null;
}
/**
* 管理员超时借阅模糊查询
* @param bookId
* @param readId
* @param readerName
* @param bookName
* @return
*/
public List<Borrow> selectOverByOthers( String readerName, String bookName){
Connection con = DBUtil.getConnection();
String sql = "select id_book, book.name as bookname, id_reader, user.name as username, time_return_should, time_return_real from user,book,borrow where user.id=id_reader and book.id=id_book and timeout=1 and user.name like \"%\"?\"%\" and book.name like \"%\"?\"%\"";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, readerName);
ps.setString(2, bookName);
ResultSet rs = ps.executeQuery();
List<Borrow> borrowList = rsToBorrows(rs);
return borrowList;
}
catch (SQLException e) {
return null;
}
finally {
DBUtil.closeConnection(con);
}
}
return null;
}
/**
* 管理员当前借阅查询,根据读者id和图书id和其他
* @param bookId
* @param readId
* @param readerName
* @param bookName
* @return
*/
public List<Borrow> selectByBookIdReaderId( String bookId, String readId, String readerName, String bookName){
Connection con = DBUtil.getConnection();
String sql = "select id_book, book.name as bookname, id_reader, user.name as username, time_borrow, time_return_should from user,book,borrow where user.id=id_reader and book.id=id_book and time_return_real IS NULL and book.id=? and user.id=? and user.name like \"%\"?\"%\" and book.name like \"%\"?\"%\"";
PreparedStatement ps = null;
if (con != null) {
try {
ps = con.prepareStatement(sql);
ps.setString(1, bookId);
ps.setString(2, readId);
ps.setString(3, readerName);
ps.setString(4, bookName);
ResultSet rs = ps.executeQuery();
List<Borrow> borrowList = rsToBorrows(rs);
return borrowList;
}
catch (SQLException e) {
return null;
}
finally {
DBUtil.closeConnection(con);
}
}
return null;
}
/**
* 管理员历史借阅查询,根据读者id和图书id和其他
* @param bookId
* @param readId
* @param readerName
* @param bookName
* @return
*/
public List<Borrow> selectPastByBookIdReaderId( String bookId, String readId, String readerName, String bookName){
Connection con = DBUtil.getConnection();
String sql = "select id_book, book.name as bookname, id_reader, user.name as username, time_borrow
没有合适的资源?快使用搜索试试~ 我知道了~
java图书管理系统项目源码
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共99个文件
png:51个
java:38个
jar:3个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 71 浏览量
2024-06-16
10:33:57
上传
评论
收藏 8.99MB ZIP 举报
温馨提示
# 程序入口为src/demo/Main.java # 执行程序之前需要先填写properties文件中的password(数据库密码) # 不要修改properties文件中的booksystem数据库的名称 # 注册身份只能是借阅者,图书管理员和系统管理员只能通过系统管理员手动添加 # 系统管理员: 0000 00Aa # 图书管理员: 1111 11Aa # 借阅者: 2222 22Aa
资源推荐
资源详情
资源评论
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 99 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/2c8c20c5e95b46c58afd0a0d87fe23db_huayula.jpg!1)
酷爱码
- 粉丝: 6713
- 资源: 1088
![benefits](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-1.c8e153b4.png)
下载权益
![privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-2.ec46750a.png)
C知道特权
![article](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-3.fc5e5fb6.png)
VIP文章
![course-privilege](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-4.320a6894.png)
课程特权
![rights](https://csdnimg.cn/release/downloadcmsfe/public/img/vip-rights-icon.fe0226a8.png)
开通VIP
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- IMG20240303105441.jpg
- 高校教材管理系统数据库文件
- 我的电竞赛场之旅:从新手到冠军的经验分享
- SSA-CNN-BiLSTM麻雀算法优化卷积双向长短期记忆神经网络数据分类预测(Matlab完整源码和数据)
- 可直接运行 基于MATLAB的GPS网平差计算方法 简易MATLAB源代码计算规则 含Excel数据.rar
- 公司自助餐管理系统数据库文件
- CSP比赛经验分享:从入门到提高 CSP比赛中的一些经验和心得
- python贪吃蛇完整代码
- 中学排课管理系统数据库文件
- Python 简易文件系统模拟:设计一个简单的文件系统,实现文件的创建、读写、删除和目录管理等操作,可以考虑文件权限、路径解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)