package com.wwcxy.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.sun.org.apache.regexp.internal.recompile;
import com.wwcxy.entity.AdminEntity;
import com.wwcxy.entity.LendRecord;
import com.wwcxy.util.JdbcUtil;
public class LendRecordDao extends JdbcUtil{
//查询所有图书信息
public List<LendRecord> getAllLendRecordBypage(int page,int limit){
List<LendRecord> list = new ArrayList<LendRecord>();
Connection conn = this.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String sql="select * from lendrecord limit ?,?";
try {
ps = conn.prepareStatement(sql);
ps.setInt(1, (page-1)*limit);
ps.setInt(2, limit);
rs = ps.executeQuery();
while(rs.next()){
LendRecord lr = new LendRecord();
lr.setLid(rs.getInt("lid"));
lr.setBid(rs.getInt("bid"));
lr.setBname(new LendRecordDao().getBnameBybid(rs.getInt("bid")));
lr.setCid(rs.getInt("cid"));
lr.setCname(new LendRecordDao().getCnameBycid(rs.getInt("cid")));
lr.setBorrowtime(rs.getString("borrowtime"));
lr.setDeadline(rs.getString("deadline"));
lr.setReturntime(rs.getString("returntime"));
lr.setStatus(rs.getString("status"));
list.add(lr);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
this.close(conn, ps, rs);
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
//新增图书信息
public int addLr(LendRecord lr){
int row = 0;
Connection con=this.getConnection();
PreparedStatement ps=null;
String sql="insert into lendrecord"
+ "(lid,bid,cid,borrowtime,deadline,returntime,status) values(?,?,?,?,?,?,?)";
try {
ps=con.prepareStatement(sql);
ps.setInt(1,lr.getLid());
ps.setInt(2,lr.getBid());
ps.setInt(3,lr.getCid());
ps.setString(4,lr.getBorrowtime());
ps.setString(5,lr.getDeadline());
ps.setString(6, lr.getReturntime());
ps.setString(7,lr.getStatus());
row=ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
this.close(con, ps, null);
} catch (SQLException e) {
e.printStackTrace();
}
}
return row;
}
//根据lid修改图书信息
public int updateLrByLid(LendRecord lr){
int row = 0;
Connection con = this.getConnection();
PreparedStatement ps = null;
String sql = "update lendrecord set cid=?,borrowtime=?,returntime=?,status=? where lid=?";
try {
ps=con.prepareStatement(sql);
ps.setInt(1,lr.getCid());
ps.setString(2,lr.getBorrowtime());
ps.setString(3,lr.getReturntime());
ps.setString(4,lr.getStatus());
ps.setInt(5, lr.getLid());
row=ps.executeUpdate();
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
}finally{
try {
this.close(con, ps, null);
} catch (SQLException e) {
// TODO: handle exception
e.printStackTrace();
}
}
return row;
}
//删除图书信息
public int delLrByLid(int lid){
int row=0;
Connection con=this.getConnection();
PreparedStatement ps=null;
String sql="delete from lendrecord where lid=?";
try {
ps=con.prepareStatement(sql);
ps.setInt(1,lid);
row=ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
this.close(con, ps, null);
} catch (SQLException e) {
e.printStackTrace();
}
}
return row;
}
//根据cid查询图书信息
public List<LendRecord> getlrByCid(int cid ,int page,int limit){
List<LendRecord> list = new ArrayList<LendRecord>();
Connection con = this.getConnection();
PreparedStatement ps=null;
ResultSet rs=null;
String sql="select * from lendrecord where cid like ? limit ?,?";
try {
ps=con.prepareStatement(sql);
ps.setString(1, cid+"");
ps.setInt(2, (page-1)*limit);
ps.setInt(3, limit);
rs=ps.executeQuery();
while(rs.next()){
LendRecord lr = new LendRecord();
lr.setLid(rs.getInt("lid"));
lr.setBid(rs.getInt("bid"));
lr.setBname(new LendRecordDao().getBnameBybid(rs.getInt("bid")));
lr.setCid(rs.getInt("cid"));
lr.setCname(new LendRecordDao().getCnameBycid(rs.getInt("cid")));
lr.setBorrowtime(rs.getString("borrowtime"));
lr.setDeadline(rs.getString("deadline"));
lr.setReturntime(rs.getString("returntime"));
lr.setStatus(rs.getString("status"));
list.add(lr);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
this.close(con, ps, rs);
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
//根据lid查询图书信息
public LendRecord getLrByLid(int lid){
LendRecord lendrecord = new LendRecord();
Connection con = this.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select * from lendrecord where lid = ?";
try {
ps = con.prepareStatement(sql);
ps.setInt(1, lid);
rs = ps.executeQuery();
while(rs.next()){
lendrecord.setLid(rs.getInt("lid"));
lendrecord.setBid(rs.getInt("bid"));
lendrecord.setBname(new LendRecordDao().getBnameBybid(rs.getInt("bid")));
lendrecord.setCid(rs.getInt("cid"));
lendrecord.setCname(new LendRecordDao().getCnameBycid(rs.getInt("cid")));
lendrecord.setBorrowtime(rs.getString("borrowtime"));
lendrecord.setDeadline(rs.getString("deadline"));
lendrecord.setReturntime(rs.getString("returntime"));
lendrecord.setStatus(rs.getString("status"));
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
this.close(con, ps, rs);
} catch (SQLException e) {
e.printStackTrace();
}
}
return lendrecord;
}
public int getLikeCount(int cid){
Connection conn = this.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
int count = 0;
String sql = "select count(*) from lendrecord where cid like ?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "%"+cid+"%");
rs = pstmt.executeQuery();
while(rs.next()){
count = rs.getInt("count(*)");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
rs.close();
pstmt.close();
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return count;
}
//借书
public int Borrowtime(int cid) {
int row = 0;
Connection con = this.getConnection();
PreparedStatement ps = null;
String sql = "insert into lendrecord (cid,borrowtime,status,deadline) values(?,?,?,?)";
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd");
String nowtime = df.format(new Date());
try {
ps = con.prepareStatement(sql);
ps.setInt(1, cid);
ps.setString(2, nowtime);
ps.setString(3, "未还书");
ps.setString(4, df1.format(new Date()));
row = ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
this.close(con, ps, null);
} catch (SQLException e) {
e.printStackTrace();
}
}
return row;
}
//查看是否借书成功
public int GetBorrowtime(int cid) {
Connection con = this.getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
String sql = "select cid from lendrecord where status=?";
try {
ps = con.prepareStatement(sql);
ps.setString(1, "未还书");
rs = ps.executeQuery();
while(rs.next()){
if(cid == rs.getInt("cid")){
return 1; //已经借书成功
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
try {
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!! 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。有任何问题也可以随时私信博主,博主会第一时间给您解答!!!
资源推荐
资源详情
资源评论
![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)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![jar](https://img-home.csdnimg.cn/images/20210720083455.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)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.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/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/GIF.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/HTML.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/JAR.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JAR.png)
共 227 条
- 1
- 2
- 3
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/1ad39e95093044228d03f0d7ce161a82_zy_dreamer.jpg!1)
![avatar-vip](https://csdnimg.cn/release/downloadcmsfe/public/img/user-vip.1c89f3c5.png)
白话机器学习
- 粉丝: 1w+
- 资源: 7706
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的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)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)