package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import com.dao.BaseDAO;
import com.entity.Book;
import com.entity.BookOder;
public class BookDAO {
public boolean updateReturnBook(int bno){
Connection con = null;
PreparedStatement pstmt = null;
try {
con = BaseDAO.getConnection();
String sql = "update book1 set bcount=bcount+1 where bno=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, bno);
int rows = pstmt.executeUpdate();
if(rows > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} finally {
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
public boolean returnBook(int uno,int bno){
Connection con = null;
PreparedStatement pstmt = null;
try {
con = BaseDAO.getConnection();
String sql = "delete from showBookBorrow1 where uno=? and bno=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, uno);
pstmt.setInt(2, bno);
int rows = pstmt.executeUpdate();
if(rows > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} finally {
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
public boolean updateRBook(int bno) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = BaseDAO.getConnection();
String sql = "update book1 set num=num+1 where bno=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, bno);
int rows = pstmt.executeUpdate();
if(rows > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} finally {
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
public boolean updateBook(int bno) {
Connection con = null;
PreparedStatement pstmt = null;
try {
con = BaseDAO.getConnection();
String sql = "update book1 set bcount=bcount-1,num=num+1 where bno=?";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, bno);
int rows = pstmt.executeUpdate();
if(rows > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} finally {
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
public boolean insertBorrow(int uno,String uname,int bno,String bname,String author,String publish){
Connection con = null;
PreparedStatement pstmt = null;
try {
con = BaseDAO.getConnection();
String sql = "insert into showbookborrow1 values(?,?,?,?,?,?,sysdate,add_months(sysdate,1),0)";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, uno);
pstmt.setString(2, uname);
pstmt.setInt(3, bno);
pstmt.setString(4, bname);
pstmt.setString(5, author);
pstmt.setString(6, publish);
int rows = pstmt.executeUpdate();
if(rows > 0) {
return true;
} else {
return false;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
} finally {
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
/**
* 查询小说
* @return
*/
public ArrayList selectXiaoshuo(String xiaoshuo) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = BaseDAO.getConnection();
String sql = "select * from book1 where bclassify=? and bname like'%"+xiaoshuo+"%'";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, "小说");
rs = pstmt.executeQuery();
if(rs != null) {
ArrayList list = new ArrayList();
while(rs.next()) {
Book book = new Book();
//满足条件就与type类中获得的值进行比较
//type.setTypeid(rs.getInt("typeid"));
//type.setTypename(rs.getString("typename"));
book.setBno(rs.getInt("bno"));
book.setBname(rs.getString("bname"));
book.setAuthor(rs.getString("author"));
book.setPublish(rs.getString("publish"));
book.setBcount(rs.getInt("bcount"));
book.setBclassify(rs.getString("bclassify"));
book.setBookrack(rs.getString("bookrack"));
list.add(book);
}
return list;
} else {
return null;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} finally {
BaseDAO.closeResultSet(rs);
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
/**
* 查询文学
* @return
*/
public ArrayList selectWenxue(String wenxue) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = BaseDAO.getConnection();
String sql = "select * from book1 where bclassify=? and bname like'%"+wenxue+"%'";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, "文学");
rs = pstmt.executeQuery();
if(rs != null) {
ArrayList list = new ArrayList();
while(rs.next()) {
Book book = new Book();
//满足条件就与type类中获得的值进行比较
//type.setTypeid(rs.getInt("typeid"));
//type.setTypename(rs.getString("typename"));
book.setBno(rs.getInt("bno"));
book.setBname(rs.getString("bname"));
book.setAuthor(rs.getString("author"));
book.setPublish(rs.getString("publish"));
book.setBcount(rs.getInt("bcount"));
book.setBclassify(rs.getString("bclassify"));
book.setBookrack(rs.getString("bookrack"));
list.add(book);
}
return list;
} else {
return null;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} finally {
BaseDAO.closeResultSet(rs);
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
/**
* 查询传记
* @return
*/
public ArrayList selectZhuanji(String zhuanji) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = BaseDAO.getConnection();
String sql = "select * from book1 where bclassify=? and bname like'%"+zhuanji+"%'";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, "传记");
rs = pstmt.executeQuery();
if(rs != null) {
ArrayList list = new ArrayList();
while(rs.next()) {
Book book = new Book();
//满足条件就与type类中获得的值进行比较
//type.setTypeid(rs.getInt("typeid"));
//type.setTypename(rs.getString("typename"));
book.setBno(rs.getInt("bno"));
book.setBname(rs.getString("bname"));
book.setAuthor(rs.getString("author"));
book.setPublish(rs.getString("publish"));
book.setBcount(rs.getInt("bcount"));
book.setBclassify(rs.getString("bclassify"));
book.setBookrack(rs.getString("bookrack"));
list.add(book);
}
return list;
} else {
return null;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} finally {
BaseDAO.closeResultSet(rs);
BaseDAO.closeStatement(pstmt);
BaseDAO.closeConnection(con);
}
}
/**
* 查询艺术
* @return
*/
public ArrayList selectYishu(String yishu) {
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = BaseDAO.getConnection();
String sql = "select * from book1 where bclassify=? and bname like'%"+yishu+"%'";
pstmt = con.prepareStatement(sql);
pstmt.setString(1, "艺术");
rs = pstmt.executeQuery();
if(rs != null) {
ArrayList list = new ArrayList();
while(rs.next()) {
Book book = new Book();
//
没有合适的资源?快使用搜索试试~ 我知道了~
java jsp+servlet图书管理系统源码
共119个文件
jsp:44个
class:23个
java:23个
5星 · 超过95%的资源 需积分: 50 102 下载量 23 浏览量
2014-08-16
16:59:14
上传
评论 11
收藏 2.11MB RAR 举报
温馨提示
基于java的JSP+servlet图书管理系统源码,本系统使用Oracle数据库,代码清晰,思路明了,适合初学者参考
资源推荐
资源详情
资源评论
收起资源包目录
java jsp+servlet图书管理系统源码 (119个子文件)
BookDAO.class 11KB
UserDAO.class 5KB
ShowBookBorrowDAO.class 4KB
borrowbook.class 2KB
dologin.class 2KB
doUpdateBook.class 2KB
ShowBookBorrow.class 2KB
doUpdateUser.class 2KB
BookOder.class 2KB
Book.class 2KB
doUpdatePsd.class 2KB
doUpdateBTime.class 2KB
doAddBook.class 2KB
returnbook.class 2KB
BaseDAO.class 2KB
doAddUser.class 2KB
doDeleteUser.class 2KB
doDeleteBook.class 2KB
User.class 1KB
Student.class 963B
ManagerDAO.class 271B
StudentDAO.class 271B
Manager.class 268B
.classpath 529B
org.eclipse.wst.common.component 468B
org.eclipse.wst.jsdt.ui.superType.container 49B
logo.gif 28KB
ojdbc14.jar 1.47MB
BookDAO.java 15KB
UserDAO.java 6KB
ShowBookBorrowDAO.java 5KB
borrowbook.java 2KB
doUpdateBook.java 2KB
dologin.java 2KB
BookOder.java 2KB
doAddBook.java 1KB
doUpdateUser.java 1KB
Book.java 1KB
BaseDAO.java 1KB
ShowBookBorrow.java 1KB
doUpdateBTime.java 1KB
doAddUser.java 1KB
doUpdatePsd.java 1KB
returnbook.java 1KB
doDeleteBook.java 1015B
doDeleteUser.java 1009B
User.java 931B
Student.java 548B
StudentDAO.java 52B
ManagerDAO.java 52B
Manager.java 52B
wdqbs.jpg 142KB
top.jpg 85KB
syr.jpg 82KB
welcome.jpg 68KB
bwjl.jpg 57KB
kj.jpg 57KB
top1.jpg 42KB
gly.jpg 37KB
beijing.jpg 35KB
beijing3.jpg 33KB
tyzdr.jpg 9KB
bbtzq.jpg 9KB
ynyzsjwnxy.jpg 8KB
bj8.jpg 7KB
snykzd.jpg 4KB
bj9.jpg 3KB
.jsdtscope 500B
showBookBorrow.jsp 3KB
selectshkx.jsp 2KB
selectxs.jsp 2KB
selectzj.jsp 2KB
selectwx.jsp 2KB
selectys.jsp 2KB
doLogin.jsp 2KB
index.jsp 2KB
showBook.jsp 2KB
showUpdateBook.jsp 2KB
showUser.jsp 2KB
showAllBookBorrow.jsp 2KB
Showshkx.jsp 2KB
Showxs.jsp 2KB
Showzj.jsp 2KB
Showwx.jsp 2KB
Showys.jsp 2KB
manageLibrary.jsp 2KB
Showxs1.jsp 1KB
MyLibrary.jsp 1KB
showUpdateUser.jsp 1KB
Showshkx1.jsp 1KB
Showwx1.jsp 1KB
Showzj1.jsp 1KB
Showys1.jsp 1KB
showAddBook.jsp 1KB
showManageInfo.jsp 1KB
selectorder.jsp 1KB
showUserInfo.jsp 1KB
showAddUser.jsp 1KB
selectshkx1.jsp 973B
selectxs1.jsp 969B
共 119 条
- 1
- 2
资源评论
- 找不到名字可以保存的2015-09-18代码比较清晰明了,适合初学者参考
Mrtsun
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功