1.1 主菜单
1.2 图书查询
1.3 图书入库
1.4 图书删除
1.5 图书概览
1.6 图书修改
1.7 修改密码
二、功能部分代码public int bookAdd(Book book) {
Connection connection =null;
PreparedStatement ps = null;
String sql = "insert into book (id,Name,price,editor,publisher,uploadTime)values(?,?,?,?,?,?)";
try{
connection = Dbutils.getConnection();
ps = connection.prepareStatement(sql);
ps.setInt(1, book.getBookNo());
ps.setString(2, book.getBookName());
ps.setBigDecimal(3, book.getBookPrice());
ps.setString(4, book.getBookEditor());
ps.setString(5, book.getBookPublisher());
ps.setDate(6,TranslateDate.utilToSql(book.getBookTime()));
int result = ps.executeUpdate();
return result;
}catch(SQLException e){
e.printStackTrace();
}
return 0;
}
@Override
public Book bookQuery(String bookName) {
// TODO Auto-generated method stub
Connection connection = null;
PreparedStatement ps = null;
String sql = "select * from book where name = ?";
try {
connection = Dbutils.getConnection();
ps = connection.prepareStatement(sql);
ps.setString(1, bookName);
//得到图书结果集
ResultSet resultSet = ps.executeQuery();
//判断下一行是否存在数据
while (resultSet.next()) {
//依据列名获取结果集零散数据
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
BigDecimal price = resultSet.getBigDecimal(3);
String editor = resultSet.getString(4);
String publisher = resultSet.getString(5);
Date uploadDate = resultSet.getDate(6);
//封装零散数据
Book book = new Book(id,name,price,editor,publisher,uploadDate);
return book;
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public int bookUpdate(Book book) {
Connection connection = null;
PreparedStatement ps =null;
String sql = "update book set name = ? , price = ?,editor =?,publisher=?,uploadTime=? where id =?";
try {
connection = Dbutils.getConnection();
ps = connection.prepareStatement(sql);
ps.setString(1, book.getBookName());
ps.setBigDecimal(2, book.getBookPrice());
ps.setString(3, book.getBookEditor());
ps.setString(4, book.getBookPublisher());
ps.setDate(5, TranslateDate.utilToSql(book.getBookTime()));
ps.setInt(6, book.getBookNo());
return ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
public int bookDelete(String bookName) {
Connection connection = null;
PreparedStatement ps =null;
String sql = "delete from book where name = ?";
try {
connection = Dbutils.getConnection();
ps = connection.prepareStatement(sql);
ps.setString(1, bookName);
return ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
return 0;
}
public List bookQueryAll() {
Connection connection = null;
PreparedStatement ps =null;
String sql = "select * from book";
try {
connection = Dbutils.getConnection();
ps = connection.prepareStatement(sql);
ResultSet resultSet = ps.executeQuery();
List list = new ArrayList<>();
//判断下一行是否存在数据
while (resultSet.next()) {
//依据列名获取结果集零散数据
int id = resultSet.getInt(1);
String name = resultSet.getString(2);
BigDecimal price = resultSet.getBigDecimal(3);
String editor = resultSet.getString(4);
String publisher = resultSet.getString(5);
Date uploadDate = resultSet.getDate(6);
//封装零散数据
Book book = new Book(id,name,price,editor,publisher,uploadDate);
list.add(book);
}
return list;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
三、数据库表
1. 图书表
2. 用户表
本篇未展示整个系统代码和数据库,如有需要本系统源码、课设文档和远程辅导,加QQ:1411720451(备注图书管理系统)



