📄 select.java~33~
字号:
package bbs.beans.select;
import bbs.beans.dbcontact.ContactBean;
import java.util.Vector;
import java.lang.Integer;
import java.sql.*;
class Select
{
private Statement stm;
private ResultSet result;
private String sql;
private Vector v;
public int curpage;//当前是多少页
public int pagenum;//一共有多少页
public int rownum;//一共有多少行
public int rowsperpage=16;//每页有多少行
public Select()
{
ContactBean contact=new ContactBean();
stm=contact.getStm();
}
private void getRownum()throws Exception
{
int ret=0;
result=stm.executeQuery("select * from topicplan,boardinfo where "+sql);
if(result.next())
ret=result.getInt(1);
this.rownum=ret;
}
private void countPageNum()
{
if (this.rownum%this.rowsperpage==0)
{
this.pagenum=this.rownum/this.rowsperpage;
}
else
{
this.pagenum=this.rownum/this.rowsperpage+1;
}
}
//
public Vector listData(String sql,String page)
{
int i=0;
this.sql=sql;
int num=Integer.parseInt(page);//.获得当前的页面号
try
{
this.getRownum();
this.countPageNum();
result=stm.executeQuery("select top "+num*rowsperpage+" * from topicplan,userinfo where "+sql
+" and replyplan.userid=userinfo.userid order by replyplan.childid asc");
while(result.next())
{
if(i>(num-1)*rowsperpage-1)
{
Object[] obj=new Object[14];
obj[0]=result.getString("parentid") ;
obj[1]=result.getString("childid");
obj[2]=result.getString("userid");
obj[3]=result.getDate("pubtime");
obj[4]=result.getString("topic");
obj[5]=result.getString("text");
obj[6]=result.getString("moodnum");
obj[7]=result.getString("username");
obj[8]=result.getString("usersex");
obj[9]=result.getString("usersign");
obj[10]=result.getString("online");
obj[11]=result.getString("plans");
obj[12]=result.getString("registerdate");
obj[13]=result.getString("facenum");
v.add(obj);
}
i++;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -