图书馆管理系统,具体功能包括:
1. 用户登录
2. 用户注册
3. 新图书入库
4. 图书信息查询
5. 图书更新(修改)
6. 旧图书删除
7. 办理借阅证登记
8. 图书借阅管理
完整项目:https://download.csdn.net/download/sger123/12887202
//数据库连接 MySQL:8.0.14
public class DBConnection {
public static final String DRIVER ="com.mysql.cj.jdbc.Driver";
public static final String URL="jdbc:mysql://localhost:3306/library_management_system?serverTimezone=GMT%2B8";
//library_management_system 是自己创建的数据库名字
// public static final String URL="jdbc:mysql://localhost:3306/library_management_system";mysql5.0的
public static final String USER="root";
public static final String PASSWORD="123456";
Connection conn =null;
public DBConnection(){
try{
Class.forName(DRIVER);
}catch (ClassNotFoundException e) {
e.printStackTrace();
}
try{
conn= DriverManager.getConnection(URL,USER,PASSWORD);
}catch (SQLException e) {
e.printStackTrace();
}
}
public Connection getConnection(){
return this.conn;
}
public void close(){
if(this.conn!=null){
try{
this.conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
管理员表
图书表
读者表
借阅表
借阅表的外键关系
javaBean
//图书类
public class Book {
private int book_id; //图书编号
private String book_name; //书名
private String book_author; //作者
private String book_press; //出版社
public Book(int book_id, String book_name, String book_author, String book_press) {
this.book_id = book_id;
this.book_name = book_name;
this.book_author = book_author;
this.book_press = book_press;
}
public int getBook_id() {
return book_id;
}
public void setBook_id(int book_id) {
this.book_id = book_id;
}
public String getBook_name() {
return book_name;
}
public void setBook_name(String book_name) {
this.book_name = book_name;
}
public String getBook_author() {
return book_author;
}
public void setBook_author(String book_author) {
this.book_author = book_author;
}
public String getBook_press() {
return book_press;
}
public void setBook_press(String book_press) {
this.book_press = book_press;
}
//读者类
public class User {
private int user_id; //借阅证
private String user_name;
private int user_age;
private String user_sex;
private String user_phone;
public User(int user_id, String user_name, int user_age, String user_sex, String user_phone) {
this.user_id = user_id;
this.user_name = user_name;
this.user_age = user_age;
this.user_sex = user_sex;
this.user_phone = user_phone;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public int getUser_age() {
return user_age;
}
public void setUser_age(int user_age) {
this.user_age = user_age;
}
public String getUser_sex() {
return user_sex;
}
public void setUser_sex(String user_sex) {
this.user_sex = user_sex;
}
public String getUser_phone() {
return user_phone;
}
public void setUser_phone(String user_phone) {
this.user_phone = user_phone;
}
}
//借阅类
public class Borrow {
private int user_id;
private int book_id;
public Borrow(int user_id, int book_id) {
this.user_id = user_id;
this.book_id = book_id;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public int getBoo