* 得到当前页数 * @return */
public int getCurrentlyPage() { } /**
* 设置当前页数
* @param currentlyPage */
public void setCurrentlyPage(int currentlyPage) { } /** * 分页查询
* @param page 当前页数 * @return */
public List<Book> myBookPaginQuery(int page){
List<Book> bookList = new ArrayList<Book>();
int num = (page-1) * this.PAGEROW; //要被排除的行数
String sql = "SELECT top("+this.PAGEROW+") * FROM TBL_BOOK WHERE try {
PreparedStatement ps =
this.currentlyPage = currentlyPage; return currentlyPage;
book_id NOT IN (SELECT TOP("+num+") book_id FROM TBL_BOOK)";
super.getConn().prepareStatement(sql);//预编译 SQL 指令并把预编译好的 SQL 存储在 PreparedStatement 对象中
ResultSet rs = ps.executeQuery(); //执行预编译好的 SQL 指令,并while (rs.next()) {//通过 while 循环迭代出结果集中的所有数据,并把
把获得的查询结果集存储在 ResultSet 对象中 它们存储在 List<Book> 集合中 Book book = new Book();
book.setBook_id(rs.getInt("book_id"));
book.setBook_name(rs.getString("book_name")); book.setBook_num(rs.getString("book_num")); book.setBook_author(rs.getString("book_author")); book.setBook_price(rs.getDouble("book_price")); book.setBook_synopsis(rs.getString("book_synopsis"));
book.setBook_publishTime(rs.getString("book_publishTime"));