// The paging method uses arraylist to save the result because if the resultset is used to save the result, the resultset requires that the database store the connection at any time. Once the database is disconnected, the RS data is gone. Public arraylist getfenye (INT pagenow) {arraylist Al = new arraylist (); // 1. connect to the database Ct = new conndb (). getconn (); // basic paging algorithm string SQL = "select * from (select T. *, rownum rn from "+" (select * from users order by userid) t "+" where rownum <= "+ pagesize * pagenow + ") where rn> = "+ (pagesize * (pageNow-1) + 1); try {PS = CT. preparestatement (SQL); RS = ps.exe cutequery (); // retrieve a record // each time a record is retrieved, it is put into a userbean while (RS. next () {userbean UB = new userbean (); ub. setuserid (RS. getint (1); ub. setusername (RS. getstring (2); ub. setpasswd (RS. getstring (3); ub. setemail (RS. getstring (4); ub. setgrade (RS. getint (5); // Add UB to arraylist Al. add (UB) ;}} catch (sqlexception e) {e. printstacktrace ();} finally {// close resource dbclose Dc = new dbclose (); DC. close () ;}return Al ;}