package data; import java.sql.ResultSet; import java.util.ArrayList; import java.util.List; import entity.Book; public class BookDao { //根据图书编号,获得单个图书实体 public static Book selectBook(String id) { String sql = "select * from book where id='" + id +"'"; ResultSet rs = BaseDao.executeQuery(sql); Book book = null; try { if (rs.next()) { book = new Book(); book.setId(rs.getString("id")); book.setType(rs.getString("type")); book.setName(rs.getString("name")); book.setAuthor(rs.getString("author")); book.setTranslator(rs.getString("translator")); book.setPublisher(rs.getString("publisher")); book.setPublish_time(rs.getDate("publish_time")); book.setPrice(rs.getDouble("price")); book.setStock(rs.getInt("stock")); } } catch (Exception e) { e.printStackTrace(); } BaseDao.close(); return book; } //获得满足sql语句的图书实体列表 public static List selectBookList(String sql) { List list = new ArrayList(); ResultSet rs = BaseDao.executeQuery(sql); try { while (rs.next()) { Book book = new Book(); book.setId(rs.getString("id")); book.setType(rs.getString("type")); book.setName(rs.getString("name")); book.setAuthor(rs.getString("author")); book.setTranslator(rs.getString("translator")); book.setPublisher(rs.getString("publisher")); book.setPublish_time(rs.getDate("publish_time")); book.setPrice(rs.getDouble("price")); book.setStock(rs.getInt("stock")); list.add(book); } } catch (Exception e) { e.printStackTrace(); } BaseDao.close(); return list; } }
最近下载更多
微信网友_6445756515635200 LV3
2023年12月21日
KAIzx11 LV7
2023年6月24日
huangzy LV12
2023年6月11日
122378 LV3
2022年12月14日
微信网友_6191697646571520 LV6
2022年10月31日
13112360 LV2
2022年9月20日
gnnhka LV10
2022年6月16日
fantesy LV17
2022年5月15日
喃喵xxxx LV6
2022年5月11日
543666826 LV33
2022年3月12日
最近浏览更多
akittyboy LV9
3月22日
asddwh LV12
2023年12月26日
求学的熊猫 LV6
2023年12月25日
微信网友_6786215447367680 LV4
2023年12月21日
微信网友_6445756515635200 LV3
2023年12月21日
weilaizhisheng LV21
2023年12月5日
1143011510 LV15
2023年11月27日
李朝磊 LV18
2023年11月18日
夜猫子111 LV2
2023年11月6日
sunshine9920 LV12
2023年10月23日