栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java课设实现图书管理系统(GUI界面+Mysql数据库)

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java课设实现图书管理系统(GUI界面+Mysql数据库)

一、系统功能界面

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(备注图书管理系统)

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1013350.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号