1、java+swing+mysql图书管理系统附完整源代码课程设计精品图书If理系统书生系统说明:本系统釆用eclipse开发,IDEA, eclipse, myedipse均可运行界面采用swing实现数据库:mysql.附sql代码,其余数据库可复制sql代码运行数据库连接文件 mysql-connector-java-8.0.16.jar本系统的背景图片可根据自己的需求替换项目分为管理员和普通用户两种角色管理员有图书査询、图书借还、账户管理(修改密码、账户信息、借书记录)、图书管理(増加、修改、删除)的权限普通用户有图书査询、图书借还、账户管理(修改密码、借书记录)的权限项目结朴-温图书系
2、饨,JRE 基绽库(JavaSE-12IS src y . DaodZl AdminDao.java BookDao.javaI/) DB.javaEl LandDao.javav SB TestJZ) LandTest.javay 击 ViewABorrowBookFace.java 通 AccountMsgFacejavai AddBookFace.java(2 AdminFace.javaLfi BookAdminFace.java BookReturnFace.javaSi BookSearc h Fac e.javaDeleteBookFace.javaJZ) LogonFace.j
3、avaSi MainFace.javaJZl UBorrowBookFace.javaUpdatePswFace.javaE) UserFace.java i引用的阵y 4 datebase圍 tsglsys.sqlimg。admin.jpeg。bg1.jpg。login.jpgmainbg.jpgy lib耳 mysql-connector-java-8.0.16.jar登录界面:管理员登录:蘇号root,密码123123普通用户登录:账号123,密码123123注册界面:管理员主界面:E W ill fflHWW图书査询界面,I 齐血 IM BA* MKftW图书查训讷逸拝査询方式:y松.
4、 捜水图书借还界面,| w imka* wihih- mw mnnw 图书借还检室埔输入书号,竹名: 作帝 状妇ifc账户管理界面:图书管理界面:图书管理*MNHCaWAIVKGUM&NIISGft添加图书界面:添加图书类别:膑弄类琳 ,书名: 2J作者:出版社:价格:确定修改图书界面:修改图书信息15 ;: I类别:页逸择晒书名:作者:出版社:状态:。馆价格:确定账户值息界面:账户信息AH5记录界面:借书记录普通用户主界面:普通用户際户管理界面:账户管理背景图片,数据库文件(tsglsys.Sql):SET NAMES utf8mb4;SET FOREIGN_KEY_CHECKS = 0;D
5、ROP TABLE IF EXISTS bookcategory*;CREATE TABLE bookcategory (Category varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 1 类别,PRIMARY KEY (Category) USING BTREE)ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW.FORMAT = Compact;INSERT INTO bookcategory VALUES (军
6、事);INSERT INTO bookcategory VALUES (天文);INSERT INTO bookcategory VALUES (学术);INSERT INTO bookcategory VALUES (小说);INSERT INTO bookcategory VALUES (文艺);INSERT INTO bookcategory VALUES (科幻);INSERT INTO bookcategory VALUES (经济);DROP TABLE IF EXISTS booktable,;CREATE TABLE booktable (bookid int(10) NOT
7、NULL AUTOJNCREMENT COMMENT书号,category varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 类别,bookname varchar(lOO) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT书名,author varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT作者,press varchar
8、(lOO) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT出版社,price float(10, 2) NOT NULL COMMENT价格state varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMEN状态PRIMARY KEY ( bookid*) USING BTREE,INDEX category(category) USING BTREE,CONSTRAINT booktable_ibfk_l* FOREIG
9、N KEY (category) REFERENCES bookcategory ( Category*) ON DELETE RESTRICT ON UPDATE CASCADE)ENGINE = InnoDB AUTOJNCREMENT = 21 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW.FORMAT = Compact;INSERT INTO booktable VALUES (1,,学术。JAVA程序设计教程*,刘志宏航空工业出版 社)45.00,在馆,);INSERT INTO booktable* VALUES (2,,学
10、术,软件工程,程成机械工业出版社,31.50, * 在馆);INSERT INTO booktable VALUES (3,学术* (计算机文化(美)帕森斯(Parsons JJf,电子工 业出版社28.00,,在馆;INSERT INTO booktable VALUES (4,,文艺我在未来等你,刘同,青年光影出版社 36.50,,在馆);INSERT INTO booktable VALUES (5,小说,西游记吴承恩岳麓出版社33.50,,在馆,);INSERT INTO booktable* VALUES (6,学术数据结构(c语言) 严蔚敏清华大学出版 社27.50,,在馆,);I
11、NSERT INTO booktable VALUES (7, ,学术。1 C语言程序设计教程*,谭浩强清华大学出 版社,,40.00,,在馆INSERT INTO booktable VALUES (8,学术计算机文化基础,李永红,对外经济贸易大 学。32.50,在馆,);INSERT INTObooktableVALUES (9, ,学术J数据库系统实现/加西亚-莫利纳机械工 业出版社,47.00, ,在馆;INSERT INTO booktable VALUES (10,,文艺,数据库系统基础教程厄尔曼机械工业出 版社。38.50,,在馆);INSERT INTO booktable*
12、VALUES (11,学术 J数学思维导论Keith Devlin1,人民邮电出版 枇40.00,,在馆)INSERT INTO booktable VALUES (12,学术移动应用Ul设计必修课,余振华人民邮 电出版社36.00,,在馆);INSERT INTO booktable VALUES (13,,学术,1快速软件开发,史蒂夫迈克康奈尔,,清华 大学出版社*, 25.50/在馆,);INSERT INTO booktable VALUES (14,,科幻 J三体刘慈欣重庆出版社31.00,,在馆INSERT INTO booktable* VALUES (15, ,科幻,,海底两万
13、里 ,镭尔凡尔纳,,译林出版社 32.50,,在馆INSERT INTO booktable VALUES (16,军事狼牙刘猛北京联合出版公司35.50,,在 馆;INSERT INTO ,booktable VALUES (17,天文宇宙的琴弦布赖恩格林,湖南科学技术 岀版社。30.00,,在馆INSERT INTO booktable VALUES (18,经济,,货币经融学弗宙德里克S米什金中国人 民大学出版社60.00/在馆;DROP TABLE IF EXISTS borrowrecords;CREATE TABLE borrowrecords* (id int(10) NOT N
14、ULL AUTOJNCREMENT COMMEN借书序列,user varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 用户 名,bookid int(10) NOT NULL COMMENT 书号,bookname varchar(SO) CHARACTER SETutf8 COLLATE utf8_general_ci NOT NULL COMMENT, 书名,borrowtime date NOT NULL COMMENT 借书时间,returntime* date NULL DEFAULT NU
15、LL COMMENT1 还书时间,status varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 状 态:PRIMARY KEY (id) USING BTREE)ENGINE = InnoDB AUTOJNCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW.FORMAT = Compact;DROP TABLE IF EXISTS usertable*;CREATE TABLE usertable* (user varcha
16、r(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 用户 名,studentid varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT 1 学号,name varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT名Ipassword* varchar(2O) CHARACTER SET utf8 COLLATE utf8_general_ci
17、 NOT NULL COMMENT 密码,admin int(10) NOT NULL COMMENT 否为管理员账户1为管理员,0为普通用户,耿 认为0,PRIMARY KEY (user) USING BTREE)ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW.FORMAT = Compact;userstudentidnamepasswordadmin123|1231231231230j 1234123412341231230rootrootroot1231231INSERT INTO usertabl
18、e VALUES (123, 123, 123, 123, 0);INSERT INTO usertable VALUES (root*, root*, root*, 123, 1);SET FOREIGN_KEY_CHECKS = 1;ft库表gbookid 3c9oybookrumcauthorprewprice Udtcn字术JAVAft序釦球询孩换2现出版吐45.00 汛12 kE工业出加3150 StS3字术计叔化伊DgXPgom J“坦孑工业出如t2800 STB4 ftZMR年光彫出或吐3&5O StS即恩3150 ECategory6Kem构(cms)砂大竽岀版牡27.SE7字
19、术任厦EH奶.t;已狰綺地大孕岀阪牡40.00 E0军爭8字术9M1対咄疥倒月大学32.50 E9字术tCE WWSlMIlkttitttt47.00 m10 J7X以5翌3砲 娅厄尔JIBUHk 出 CM3a 50 E学术11字术蚊学专姥号沦Keith Devtin入印曲出扱吐40.00 m12字天人出版吐3600 ZBB13学术25.50 E14冲=)或庆岀wt31.00 S15瞬史版壮32-SOEm科幻16 S9旅合出版公5)35.SO17叔芥&3蜘布1鴨花协3000 阪18竖济中国人抵裂蛔之60.00 &iDao 包下的 AdminDao.java:package Dao;import
20、 java.sql.*;import javax.swing.DOptionPane;public class AdminDaopublic static boolean sureuser(String user) Connection con = DB .connectDBO;PreparedStatement preSql;ResultSet rs;String sqlStr = select * from usertable where user = ? try preSql = con.prepareStatement(sqlStr);preSql.setString(l, user)
21、;rs = preSql.executeQuery();boolean flag = false;while(rs.next() flag = true;return true;)if(!flag) (return false;)con.close();return false; catch (SQLException e) (return false;)public static void modifypass(String user,String password)Connection con = DB.connectDB();PreparedStatement preSql;String
22、 sqlStr = update usertable set password=? where user = ?;try preSql = con.prepareStatement(sqlStr);preSql.setString(l, password);preSql.setString(2, user);int ok = preSql.executeUpdate();con.close();) catch (SQLException e) public static Boolean adduser(String user, String studentid, String name. St
23、ring password) (Connection con = DB.connectDB();PreparedStatement preSql;String sqlStr = insert into usertable values (?,?,?,?,0);try preSql = con.prepareStatement(sqlStr);int ok = preSql.executeUpdate();con.close();return true; catch (SQLException e) (JOptionPane.shoivMessageDiatog(null,用户名已存在 警告,D
24、OptionPane.MARNING_MESSAGE);return false;)BookDao.java:package Dao;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.table.Default!ableModel;public class BookDao public BookDao() public static void findcategory(JComboBox box) (Connection con = DB.connectDBO;PreparedStateme
25、nt preSql;ResultSet rs;String sqlStr = select * from bookcategory;try preSql = con.prepareStatement(sqlStr);rs = preSql.executeQuery();while (rs.next() String category = rs.getString(l);box.addltem(category);con.close(); catch (SQLException e) (添加图书public static void addbook(String category,String b
26、ookname,String author,String press,String price) Connection con = DB.connectDB();PreparedStatement preSql;String sqlStr = insert intobooktable(category,bookname,author,press,price,state) valuestry preSql = con.prepareStatement(sqlStr);int ok = preSql.executeUpdate();con.close();) catch (SQLException
27、 e) 修改图书public static void modifybook(int bookid,String category,String bookname,String author,String press,String state,String price) (Connection con = DB.connectDB();PreparedStatement preSql;String sqlStr = update booktable set category = ?,bookname = ? ,author = ?,press = ? ,price = ?,state = ? w
28、here bookid =try preSql = con.prepareStatement(sqlStr);preSql.setlnt(7, bookid);int ok = preSql.executeUpdate();con.close();) catch (SQLException e) )删除图书public static void deletebook(int bookid) Connection con = DB .connectDBO;PreparedStatement preSql;String sqlStr = delete from booktable where bookid = ? try preSql = con.prepareStatement(sqlStr); preSql.setInt(l, bookid);int ok = preSql.executeUpdate();con.close(); catch (SQLException e) ()/显示所有图书public static void allbook(DefaultTableModel model) Connection con = DB.connectDB();Prepa
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1