📄 bookinfodao.java
字号:
package sever.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import sever.db.ConnectionDB;
import sever.entity.BookInfo;
import sever.entity.LibrarianInfo;
public class BookInfoDAO {
boolean trueorface;
//添加书籍
public boolean save(BookInfo bean){
String sql="insert into BookInfo values('"+bean.getBookName()+
"','"+bean.getBookAuthor()+"','"+bean.getBookTypes()+
"','"+bean.getBookPrice()+
"','"+bean.getBookAmount()+"','"+bean.getBookOK()+"','"+bean.getBookInTime()+"')";
ConnectionDB connectiondb=new ConnectionDB();
connectiondb.updateData(sql);
System.out.println("书籍已存入书库!");
return true;
}
//按编号删除书本
public boolean delect(BookInfo bean){
String sql="delete from BookInfo where BookNumber like ('"+bean.getBookNumber()+"')";
ConnectionDB connectiondb=new ConnectionDB();
connectiondb.updateData(sql);
System.out.println("删除成功");
return true;
}
//按书名删除
public boolean delecttwo(BookInfo bean){
String sql="delete from BookInfo where BookName =( '"+bean.getBookName()+"')";
ConnectionDB connectiondb=new ConnectionDB();
connectiondb.updateData(sql);
System.out.println("删除成功");
return true;
}
public boolean vati(BookInfo book){
String sql="select * from BookInfo where BookName like('"+book.getBookName()+"')";
ConnectionDB con=new ConnectionDB();
con.queryData(sql);
return true;
}
//按编号 验证
public boolean retu(BookInfo book){
boolean result=false;
String sql="select * from BookInfo where BookNumber like('"+book.getBookNumber()+"%')";
ConnectionDB con=new ConnectionDB();
ResultSet rs=con.queryData(sql);
System.out.println(sql);
try {
if(rs.next()){
result=true;
}else{
result=false;
}
} catch (SQLException e) {
result=false;
}
return result;
}
//按名字验证
public boolean retu2(BookInfo book){
boolean result2=false;
String sql="select * from BookInfo where BookName like('"+book.getBookName()+"%')";
ConnectionDB con=new ConnectionDB();
ResultSet rs=con.queryData(sql);
System.out.println(sql);
try {
if(rs.next()){
result2=true;
}else{
result2=false;
}
} catch (SQLException e) {
// TODO 自动生成 catch 块
result2=false;
}
return result2;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -