java项目开发实例图书信息管理系统开发文档及源码Word格式文档下载.docx
《java项目开发实例图书信息管理系统开发文档及源码Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《java项目开发实例图书信息管理系统开发文档及源码Word格式文档下载.docx(125页珍藏版)》请在冰豆网上搜索。
![java项目开发实例图书信息管理系统开发文档及源码Word格式文档下载.docx](https://file1.bdocx.com/fileroot1/2023-1/23/a13ef653-34ab-4710-990b-df5f7a676cb3/a13ef653-34ab-4710-990b-df5f7a676cb31.gif)
出版日期
Smalldatetime
Price
价格
money
图书类别表:
TypeName
图书类型
Varchar(20)
Id
自动编号
用户信息表:
Name
姓名
Varchar
(2)
Sex
性别
Age
年龄
int
Identitycard
证件号码
Workdate
办证日期
datetime
Tel
号码
Yajin
押金
Password
密码
Nvarchar(10)
admin
管理员
Nchar(10)
读者信息表:
Varchar(10)
identityCard
日期
manNum
最大书量
Varchar(15)
keepMoney
Miney
Zj
证件类型
Zy
职业
bztime
办证时间
三、系统源代码:
C//数据库的连接与操作类
packagecom.zhang.dao;
importjava.sql.Connection;
import.Date;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.util.ArrayList;
importjava.util.List;
importcom.zhang.model.BookInfo;
importcom.zhang.model.BookType;
importcom.zhang.model.Operator;
importcom.zhang.model.Reader;
importcom.zhang.model.User;
publicclassDao{
protectedstaticStringdbClassName="
com.microsoft.sqlserver.jdbc.SQLServerDriver"
;
protectedstaticStringdbUrl="
jdbc:
sqlserver:
//localhost:
1433;
"
+"
DatabaseName=db_lib;
SelectMethod=Cursor"
protectedstaticStringdbUser="
sa"
protectedstaticStringdbPwd="
zhangyong"
protectedstaticStringsecond=null;
privatestaticConnectionconn=null;
//创立数据库连接
privateDao(){
try{
if(conn==null){
Class.forName(dbClassName).newInstance();
conn=DriverManager.getConnection(dbUrl,dbUser,dbPwd);
System.out.println("
数据库连接成功!
);
}
else
return;
}catch(Exceptionee){
ee.printStackTrace();
//执行查询
privatestaticResultSetexecuteQuery(Stringsql){
if(conn==null)
newDao();
returnconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE).executeQuery(sql);
}catch(SQLExceptione){
e.printStackTrace();
returnnull;
}finally{
//执行更新
privatestaticintexecuteUpdate(Stringsql){
returnconn.createStatement().executeUpdate(sql);
System.out.println(e.getMessage());
//if(e.getMessage().equals("
[Microsoft][SQLServer2000DriverforJDBC][SQLServer]DELETE语句与COLUMNREFERENCE约束'
FK_TB_BORRO_REFERENCE_TB_BOOKI'
冲突。
该冲突发生于数据库'
db_library'
,表'
tb_borrow'
column'
bookISBN'
。
))
return-1;
//关闭数据库
publicstaticvoidclose(){
conn.close();
}finally{
conn=null;
}
/*
*管理员登录方法
*/
publicstaticOperatorcheck(Stringname,Stringpassword){
inti=0;
Operatoroperater=newOperator();
Stringsql="
select*fromtb_operatorwherename='
+name
'
andpassword='
+password+"
andadmin=1"
ResultSetrs=Dao.executeQuery(sql);
while(rs.next()){
Stringnames=rs.getString
(1);
operater.setId(rs.getString("
id"
));
operater.setName(rs.getString("
name"
operater.setGrade(rs.getString("
admin"
operater.setPassword(rs.getString("
password"
if(names!
=null){
i=1;
}catch(Exceptione){
Dao.close();
returnoperater;
*查询类别方法
//查询图书目录
publicstaticListselectBookCategory(){
Listlist=newArrayList();
select*fromtb_bookType"
BookTypebookType=newBookType();
bookType.setId(rs.getString("
bookType.setTypeName(rs.getString("
typeName"
list.add(bookType);
returnlist;
publicstaticListselectBookCategory(StringbookType){
selectdaysfromtb_bookTypewheretypeName='
+bookType+"
BookTypetype=newBookType();
type.setDays(rs.getString("
days"
list.add(type);
*图书类别表相关操作
*
//插入图书类型
publicstaticintInsertBookType(StringbookTypeName){
inti=0;
try{
Stringsql="
insertintotb_bookType(typeName)values('
+bookTypeName+"
)"
i=Dao.executeUpdate(sql);
}catch(Exceptione){
returni;
//更新图书类别
publicstaticintUpdatebookType(Stringid,StringtypeName){
updatetb_bookTypesettypeName='
+typeName+"
whereid='
+id+"
//System.out.println(sql);
//删除图书类别
publicstaticintDelbookType(Stringid){
deletefromtb_bookTypewhereid='
*图书信息表相关操作
*插入图书信息方法
//插入图书信息
publicstaticintInsertbook(StringISBN,StringtypeId,Stringbookname,Stringwriter,Stringtranslator,Stringpublisher,Datedate,Doubleprice){
insertintotb_bookInfo(ISBN,typeId,bookname,writer,translator,publisher,date,price)values('
+ISBN+"
'
+typeId+"
+bookname+"
+writer+"
+translator+"
+publisher+"
+date+"
"
+price+"
*查询图书相关信息
publicstaticListselectBookInfo(){
select*fromtb_bookInfo"
BookInfobookinfo=newBookInfo();
bookinfo.setISBN(rs.getString("
ISBN"
bookinfo.setTypeid(rs.getString("
typeid"
bookinfo.setBookname(rs.getString("
bookname"
bookinfo.setWriter(rs.getString("
writer"
bookinfo.setTranslator(rs.getString("
translator"
bookinfo.setPublisher(rs.getString("
publisher"
bookinfo.setDate(rs.getDate("
date"
bookinfo.setPrice(rs.getDouble("
price"
list.add(bookinfo);
publicstaticListselectBookInfo(StringISBN){
select*fromtb_bookInfowhereISBN='
*修改图书信息方法
//更新图书信息
publicstaticintUpdatebook(StringISBN,StringtypeId,Stringbookname,Stringwriter,Stringtranslator,Stringpublisher,Datedate,Doubleprice){
updatetb_bookInfosetISBN='
typeId='
bookname='
writer='
translator='
publisher='
date='
price="
whereISBN='
///*
//*删除图书信息方法
//*/
publicstaticintDelbook(StringISBN){
deletefromtb_bookInfowhereISBN='
*对读者信息表执行的相关操作
//增加读者信息
publicstaticintInsertReader(Stringname,Stringsex,Stringage,StringidentityCard,Datedate,StringmaxNum,Stringtel,DoublekeepMoney,Stringzj,Stringzy,Datebztime,StringISBN){
insertintotb_reader(name,sex,age,identityCard,date,maxNum,tel,keepMoney,zj,zy,bztime,ISBN)values('
+name+"
+sex+"
+age+"
+identityCard+"
+maxNum+"
+tel+"
+keepMoney+"
+zj+"
+zy+"
+bztime+"
System.out.println(sql);
publicstaticListselectReader(){
select*fromtb_reader"
Readerreader=newReader();
//reader.setId(rs.getString("
reader.setName(rs.getString("
reader.setSex(rs.getString("
sex"
reader.setAge(rs.getString("
age"
reader.setIdentityCard(rs.getString("
identityCard"
reader.setDate(rs.getDate("
reader.setMaxNum(rs.getString("
maxNum"
reader.setTel(rs.getString("
tel"
reader.setKeepMoney(rs.getDouble("
keepMoney"
reader.setZj(rs.getInt("
zj"
reader.setZy(rs.getString("
zy"
reader.setISBN(rs.getString("
reader.setBztime(rs.getDate("
bztime"
list.add(reader);
publicstaticListselectReader(StringreaderISBN){
select*fromtb_reader