package cn.book.dao;
import cn.book.pojo.Book;
import cn.book.pojo.BookLendType;
import cn.book.pojo.Info;
import cn.book.pojo.User;
import cn.book.util.ConnectionFactory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class FileDaoImpl implements FileDao{
@Override
public List<User> getAllUser() {
List<User> arr = new ArrayList<User>();
Connection connection = ConnectionFactory.getConnection();
PreparedStatement pre = null;
ResultSet res = null;
try {
String sql = "select * from user where u_id!=0";
System.out.println(sql);
try {
pre = connection.prepareStatement(sql);
res = pre.executeQuery();
while (res.next()){
User u = new User();
u.setUid(res.getString("u_id"));
u.setName(res.getString("u_name"));
u.setSex(res.getString("u_sex"));
u.setIdcard(res.getString("u_idcard"));
u.setU_times(res.getInt("u_times"));
u.setPwd(res.getString("u_pwd"));
u.setState(res.getInt("u_state"));
u.setRole(res.getInt("u_role"));
arr.add(u);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
@Override
public User getUserByidOrName(String admid) {
Connection connection = ConnectionFactory.getConnection();
PreparedStatement pre = null;
ResultSet res = null;
User u = null;
try {
String sql = "select * from `user` where u_id='"+admid+"' or u_name like '%"+admid+"%'";
System.out.println(sql);
try {
pre = connection.prepareStatement(sql);
res = pre.executeQuery();
while (res.next()){
u = new User();
u.setUid(res.getString("u_id"));
u.setName(res.getString("u_name"));
u.setSex(res.getString("u_sex"));
u.setIdcard(res.getString("u_idcard"));
u.setU_times(res.getInt("u_times"));
u.setPwd(res.getString("u_pwd"));
u.setState(res.getInt("u_state"));
u.setRole(res.getInt("u_role"));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return u;
}
@Override
public List<Book> getAllBook() {
List<Book> arr = new ArrayList<Book>();
Connection connection = ConnectionFactory.getConnection();
PreparedStatement pre = null;
ResultSet res = null;
try {
String sql = "select * from books";
try {
pre = connection.prepareStatement(sql);
res = pre.executeQuery();
while (res.next()){
Book book = new Book();
book.setBook_id(res.getString("book_id"));
book.setBook_name(res.getString("book_name"));
book.setBook_type(res.getString("book_type"));
book.setBook_num(res.getString("book_num"));
book.setBook_price(res.getDouble("book_price"));
book.setBook_lend(res.getInt("book_lend"));
book.setBook_ISBN(res.getString("book_ISBN"));
book.setBook_address(res.getString("book_address"));
book.setBook_business(res.getString("book_business"));
book.setBook_author(res.getString("book_author"));
book.setBook_edition(res.getString("book_edition"));
book.setBook_times(res.getInt("book_times"));
arr.add(book);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
@Override
public List<Book> getBookByNameOrId(String goalFile) {
System.out.println(goalFile);
List<Book> arr = new ArrayList<Book>();
Connection connection = ConnectionFactory.getConnection();
PreparedStatement pre = null;
ResultSet res = null;
try {
String sql = "select * from books where book_id='"+goalFile+"' or book_name like '%"+goalFile+"%' or book_type like '%"+goalFile+"%'";
System.out.println(sql);
try {
pre = connection.prepareStatement(sql);
res = pre.executeQuery();
while (res.next()){
Book book = new Book();
book.setBook_id(res.getString("book_id"));
book.setBook_name(res.getString("book_name"));
book.setBook_type(res.getString("book_type"));
book.setBook_num(res.getString("book_num"));
book.setBook_price(res.getDouble("book_price"));
book.setBook_lend(res.getInt("book_lend"));
book.setBook_ISBN(res.getString("book_ISBN"));
book.setBook_address(res.getString("book_address"));
book.setBook_business(res.getString("book_business"));
book.setBook_author(res.getString("book_author"));
book.setBook_edition(res.getString("book_edition"));
book.setBook_times(res.getInt("book_times"));
arr.add(book);
}
} catch (SQLException throwables) {
throwables.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return arr;
}
@Override
public void upBookNum(String bookId, String number, String price) {
/*
* 这个地方对数据库是不是就是 改变数据库
* 不是查询数据库
* 所以 我们在这个地方写相应的sql语句
* 然后设置以后函数专门处理sql语句
*
* */
String sql = "UPDATE books SET book_num="+number+",book_price="+price+" WHERE book_id='"+bookId+"'";
deal(sql);
}
@Override
public void addBook(String a, String b, String c, String d, String e, String f, String g, String h, String l) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
String bid = "b"+sdf.format(date);
String sql = "insert into books values('"+bid+"','"+a+"','"+b+"',"+c+","+d+",0,'"+e+"','"+f+"','"+g+"','"+h+"','"+l+"',0)";
deal(sql);
}
public List<BookLendType> getLendFiles(String sql){
Connection connection = ConnectionFactory.getConnection();
PreparedStatement pre = null;
ResultSet res = null;
List<BookLendType> list = null;
try {
try {
list = new ArrayList<BookLendType>();
pre = connection.prepareStatement(sql);
res = pre.executeQuery();
while (res.next()){
BookLendType blt = new BookLendType();
blt.setLend_id(res.getString("a"));
blt
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
图书馆管理系统使用Java编写,具备图书和读者信息的录入、查询、借阅和归还功能。管理员可以方便地录入图书信息,并为每本书分配唯一编码。读者可以通过系统查询图书的可借状态,并进行借阅和归还操作。系统还提供借阅记录管理功能,管理员可以查看读者的借阅历史和逾期情况。此外,系统支持图书和读者信息的修改和删除,以及借阅情况和库存的统计。通过这个系统,图书馆能够更高效地管理图书和读者信息,提供更优质的服务。
资源推荐
资源详情
资源评论
收起资源包目录
利用JavaWeb实现图书馆管理系统 (133个子文件)
FileDaoImpl.class 13KB
FileDaoImpl.class 13KB
FileServlet.class 6KB
FileServlet.class 6KB
UserFileServlet.class 5KB
UserFileServlet.class 5KB
FileServiceImpl.class 4KB
FileServiceImpl.class 4KB
Book.class 4KB
Book.class 4KB
User.class 3KB
User.class 3KB
LogingDaoImpl.class 2KB
LogingDaoImpl.class 2KB
register.class 2KB
register.class 2KB
Login.class 2KB
Login.class 2KB
BookLendType.class 2KB
BookLendType.class 2KB
FileService.class 2KB
FileService.class 2KB
FileDao.class 2KB
FileDao.class 2KB
Main.class 1KB
Main.class 1KB
ConnectionFactory.class 1KB
ConnectionFactory.class 1KB
Test1.class 1KB
Test1.class 1KB
a.class 825B
a.class 825B
Info.class 695B
Info.class 695B
LoginServiceImpl.class 653B
LoginServiceImpl.class 653B
Regist.class 608B
Regist.class 608B
LoginService.class 185B
LoginService.class 185B
LoginDao.class 169B
LoginDao.class 169B
adm.css 257B
adm.css 257B
.gitignore 184B
improveBooks.iml 1000B
mysql-connector-java-8.0.26.jar 2.35MB
mysql-connector-java-8.0.26.jar 2.35MB
c3p0-0.9.1.2.jar 596KB
c3p0-0.9.1.2.jar 596KB
standard.jar 343KB
standard.jar 343KB
jstl.jar 17KB
jstl.jar 17KB
FileDaoImpl.java 15KB
FileServlet.java 10KB
UserFileServlet.java 7KB
Book.java 4KB
FileServiceImpl.java 3KB
User.java 2KB
LogingDaoImpl.java 2KB
Login.java 2KB
BookLendType.java 1KB
Main.java 1KB
register.java 1KB
FileService.java 1KB
FileDao.java 1KB
ConnectionFactory.java 997B
Test1.java 604B
Regist.java 397B
a.java 385B
Info.java 377B
LoginServiceImpl.java 317B
LoginService.java 158B
LoginDao.java 121B
book.jsp 5KB
book.jsp 5KB
userBookLook.jsp 4KB
userBookLook.jsp 4KB
lendRecode.jsp 4KB
lendRecode.jsp 4KB
userLendRecode.jsp 3KB
userLendRecode.jsp 3KB
userFile.jsp 3KB
userFile.jsp 3KB
AddBook.jsp 3KB
AddBook.jsp 3KB
bookLend.jsp 3KB
bookLend.jsp 3KB
AdmMainPage.jsp 3KB
AdmMainPage.jsp 3KB
login.jsp 3KB
login.jsp 3KB
UserMain.jsp 2KB
UserMain.jsp 2KB
uppwd.jsp 2KB
uppwd.jsp 2KB
upBook.jsp 2KB
upBook.jsp 2KB
info.jsp 2KB
共 133 条
- 1
- 2
资源评论
汇潮学堂
- 粉丝: 4027
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- java医院人事管理系统源码数据库 MySQL源码类型 WebForm
- 道路养护病害数据集-含原图和标签
- 2023-04-06-项目笔记 - 第三百一十九阶段 - 4.4.2.317全局变量的作用域-317 -2025.11.16
- 2023-04-06-项目笔记 - 第三百一十九阶段 - 4.4.2.317全局变量的作用域-317 -2025.11.16
- 1503ANDH1503002016_20241116222825
- 时间序列-黄金-15秒数据
- C#HR人事管理系统源码数据库 MySQL源码类型 WebForm
- C#CS餐饮管理系统源码数据库 SQL2008源码类型 WinForm
- 蛾类识别系统(深度学习+UI可视化)
- 时间序列-黄金-5秒数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功