//获得所有记录集(只查询一页记录) public static List getRecords(int startIndex) { String sql = "select * from booktab limit ?,?"; sqlNumber = "select count(*) from booktab"; return DBUtil.executeQuery(sql, startIndex, recordPerPage); }
//按条件查找记录集(只查询一页记录) public static List getRecords(String key, String value, int startIndex) {
String sql = "select * from booktab where " + key + "='" + value + "' limit ?,?"; sqlNumber = "select count(*) from booktab where " + key + "='" + value + "'"; return DBUtil.executeQuery(sql, startIndex, recordPerPage); }
//查询单条记录 用于修改 public static BookBean getRecord(String value) { String sql = "select * from booktab where bookid='" + value + "'"; BookBean book = new BookBean(); book = DBUtil.execQuery(sql); return book; }
//添加一条新记录 public static int addRecord(Map newRecord) { String sql = "insert into booktab(bookname,author,publish,price,bookid)values(?,?,?,?,?)"; return DBUtil.execUpdate(sql, newRecord); }
//修改指定的记录 public static int modifyRecord(Map newRecord) { String sql = "update booktab set bookname=?,author=?,publish=?,price=? where bookid=?";