问题描述
下面时我我再dao中写的实现类,我想在点击查询时能做到分页效果,有上一页,下一页,首页,末尾页,通过页数来选择,请高手指点下吧,觉得分页挺有难度的,我知道主要是操作tablemodel,但我真的不知道怎么下手,请高手高台贵手吧。。。。packagelzz.com.myqq.server.dao.impl;importjava.sql.Connection;importjava.sql.PreparedStatement;importjava.sql.ResultSet;importjava.sql.Statement;importjava.util.Vector;importlzz.com.myqq.server.dao.db.DBPub;importlzz.com.myqq.server.dao.inf.UserDAO;importlzz.com.myqq.server.dao.vo.User;publicclassUserDAOImplimplementsUserDAO{//--SIDSNAMESPWDSSEXNAGESADDRESSNONLINEDREGDATEpublicVector<Vector<String>>findAll(Stringsid,Stringsname,intnonline){//查看所有数据//Vector<Vector<String>>allv=newVector<Vector<String>>();//StringBuildersql=newStringBuilder();sql.append("selectsid,sname,spwd,ssex,nage,nvl(saddress,'未填写')assaddress,decode(nonline,'0','不在线')asnonline,to_char(dregdate,'yyyy-mm-dd')asdregdate");sql.append("fromt_user");sql.append("where1=1");if(sid!=null&&sid.length()>0){sql.append("andsid='"+sid+"'");}if(sname!=null&&sname.length()>0){sql.append("andsnamelike'%"+sname+"%'");}if(nonline!=-1){sql.append("andnonline="+nonline);}sql.append("orderbysidasc");//3操作数据库Connectioncon=null;Statementstmt=null;ResultSetrs=null;try{con=DBPub.getcon();stmt=con.createStatement();rs=stmt.executeQuery(sql.toString());while(rs.next()){Vector<String>lineV=newVector<String>();lineV.add(rs.getString("SID"));//SIDlineV.add(rs.getString("SNAME"));//SNAMElineV.add(rs.getString("SPWD"));//SPWDlineV.add(rs.getString("SSEX"));//SSEXlineV.add(rs.getString("NAGE"));//NAGElineV.add(rs.getString("SADDRESS"));//SADDRESSlineV.add(rs.getString("NONLINE"));//NONLINElineV.add(rs.getString("DREGDATE"));//DREGDATEallv.add(lineV);}}catch(Exceptione){e.printStackTrace();}finally{DBPub.closeAll(con,stmt,rs);}returnallv;}}
解决方案
解决方案二:
该回复于2009-08-12 23:26:11被版主删除