資源簡(jiǎn)介
基于Java的圖書(shū)管理系統(tǒng),內(nèi)部包含數(shù)據(jù)庫(kù)、開(kāi)發(fā)文檔、完整代碼,使用文檔。對(duì)于該系統(tǒng)的預(yù)覽可以查看這篇博客:https://blog.csdn.net/weixin_43742062/article/details/107264098
代碼片段和文件信息
package?com.database;
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?com.entity.AdminInfor;
import?com.entity.AllBooks;
import?com.entity.ReaderInfor;
public?class?AdminAction?{
/**
?*?這個(gè)類(lèi)主要是管理員操作,對(duì)應(yīng)的數(shù)據(jù)庫(kù)SQL操作語(yǔ)句
?*?功能如下:
?*? 1.?addBooks(AllBooks?book):向書(shū)庫(kù)增加書(shū)籍
?*??2.?updateBooks(AllBooks?bookString?bookid):修改書(shū)庫(kù)書(shū)籍
?*??3.?addReader()?:注冊(cè)讀者信息
?*??4.?getAdminInfor(String?adminId)?:獲取管理員信息
?*??5.?getReaderInfor()?:獲取讀者信息
?*??6.?searchReaders(String?readerName)?:搜索讀者信息
?*/
public?int?addBooks(AllBooks?book)?{
Connection?conn?=?DatabaseConfig.getConnection();
try?{
String?sql?=?“INSERT?INTO?tb_books?VALUES?(?‘“
???+?book.getbookId()?+?“‘‘“
???+?book.getbookName()?+?“‘‘“
???+?book.getbookType()?+?“‘“
???+?book.getbookNum()?+?““
???+?book.getbookPrice()+“)“;
PreparedStatement?sqlAddBookS?=conn.prepareStatement(sql);
int?res=?sqlAddBookS.executeUpdate();
return?res;
}?catch?(SQLException?e)?{
e.printStackTrace();
}
return?0;
}
public?int?updateBooks(AllBooks?bookString?bookid)?{
Connection?conn?=?DatabaseConfig.getConnection();
try?{
String?sql?=?“UPDATE?tb_books?“
???+?“SET?book_num?=?‘“?+?book.getbookNum()+“‘“
???+?“book_id?=‘“?+?book.getbookId()+“‘“
???+?“book_name?=?‘“?+?book.getbookName()+“‘“
???+?“book_type?=?‘“?+?book.getbookType()+“‘“
???+?“book_price?=?‘“?+?book.getbookPrice()+“‘“
???+?“?WHERE?book_id?=?‘“+bookid+“‘“;
PreparedStatement?sqlAddBookS?=conn.prepareStatement(sql);
int?res=?sqlAddBookS.executeUpdate();
return?res;
//?關(guān)閉連接
}?catch?(SQLException?e)?{
e.printStackTrace();
}
return?0;
}
//?注冊(cè)讀者
public?int?addReader(ReaderInfor?reader)?{
Connection?conn?=?DatabaseConfig.getConnection();
try?{
String?sql?=?“insert?into?tb_reader?“
???+?“values(‘“+reader.getreaderId()+“‘“
???+?“‘“+reader.getreaderName()+“‘“
???+?“‘“+reader.getreaderPassword()+“‘“
???+?“‘“+reader.getreaderSex()+“‘)“; ??
PreparedStatement?sqlAdd?=conn.prepareStatement(sql);
int?res=?sqlAdd.executeUpdate();
return?res;
//?關(guān)閉連接
}?catch?(SQLException?e)?{
e.printStackTrace();
}
return?0;
}
//?獲取讀者信息
public?List?getReaderInfor()?{
Connection?conn?=?DatabaseConfig.getConnection();
String?sql?=?“SELECT?*?FROM?tb_reader?“;
List?ab?=?new?ArrayList();
try?{
PreparedStatement?ps?=?(PreparedStatement)?conn.prepareStatement(sql);
ResultSet?rs?=?ps.executeQuery();
while?(rs.next())?{
ReaderInfor?reader?=?new?ReaderInfor();
reader.setreaderId(rs.getString(“reader_id“));
reader.setreaderName(rs.getString(“reader_name“));
reade
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\
?????文件?????????312??2020-08-27?22:22??Library_ManagementSystem\.git\config
?????文件??????????73??2020-08-27?22:22??Library_ManagementSystem\.git\desc
?????文件??????????23??2020-08-27?22:22??Library_ManagementSystem\.git\HEAD
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\
?????文件?????????478??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\applypatch-msg.sample
?????文件?????????896??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\commit-msg.sample
?????文件????????4655??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\fsmonitor-watchman.sample
?????文件?????????189??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\post-update.sample
?????文件?????????424??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-applypatch.sample
?????文件????????1643??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-commit.sample
?????文件?????????416??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-merge-commit.sample
?????文件????????1348??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-push.sample
?????文件????????4898??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-reba
?????文件?????????544??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\pre-receive.sample
?????文件????????1492??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\prepare-commit-msg.sample
?????文件????????3635??2020-08-27?22:22??Library_ManagementSystem\.git\hooks\update.sample
?????文件????????4703??2020-08-27?22:22??Library_ManagementSystem\.git\index
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\info\
?????文件?????????240??2020-08-27?22:22??Library_ManagementSystem\.git\info\exclude
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\logs\
?????文件?????????197??2020-08-27?22:22??Library_ManagementSystem\.git\logs\HEAD
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\heads\
?????文件?????????197??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\heads\master
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\remotes\
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\remotes\origin\
?????文件?????????197??2020-08-27?22:22??Library_ManagementSystem\.git\logs\refs\remotes\origin\HEAD
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\ob
?????目錄???????????0??2020-08-27?22:22??Library_ManagementSystem\.git\ob
............此處省略67個(gè)文件信息
- 上一篇:unity憤怒的小鳥(niǎo)
- 下一篇:JavaCP.zip
評(píng)論
共有 條評(píng)論