日期:2014-05-18  浏览次数:20855 次

高手进来改程序~
public   Vector   getContents(double   eachNum--返回行数,int   pageNum-当前业码,String   tabName-表名,String[]   fids-查询列,String   condition-排序子句,String   jspName-分业JSP)
{
Vector   contents=new   Vector();
int   max=pageNum*(int)eachNum;
int   min=(pageNum-1)*(int)eachNum;
try
{
Context   initContext=new   InitialContext();
Context   envContext=(Context)initContext.lookup( "java:/comp/env ");
DataSource   ds=(DataSource)envContext.lookup( "jdbc/sample_db ");
Connection   conn=ds.getConnection();

Statement   stmt2=conn.createStatement();
ResultSet   rs2=stmt2.executeQuery( "select   count(*)   from   "+tabName+ "   "+condition);
rs2.next();
int   totalNum=rs2.getInt(1);
rs2.close();
stmt2.close();

totalPageNum=1;
if   (totalNum/eachNum> (int)(totalNum/eachNum))
{
totalPageNum=(int)(totalNum/eachNum)+1;
}else
{
totalPageNum=(int)(totalNum/eachNum);
}
getBeforeNext(totalNum,pageNum,totalPageNum,jspName);
//System.out.print( "总共有 "+totalPageNum+ "页 "+ " <BR> ");

//开始取数据

String   sql= "select   *   from(select   a.*,rownum   r   from   (select   ";
for   (int   m=0;m <fids.length-1;m++   )
{
sql=sql+fids[m]+ ", " ;
}
sql=sql+fids[fids.length-1];
sql=sql+ "   from   "+tabName+ "   order   by   id   desc)a   where   rownum <= "+max+ ")   b   where   r> "+min+ "   "+condition;


//System.out.println( "sql: "+sql);
Statement   stmt=conn.createStatement();
ResultSet   rs=stmt.executeQuery(sql);

while   (rs.next())
{
String[]   content=new   String[fids.length];
for   (int   f=0;f <fids.length   ;f++   )
{
content[f]=rs.getString(f+1);
}
contents.add(content);
}

rs.close();
stmt.close();
conn.close();
}catch(Exception   e)
{
System.out.println( "从数据库中取值时出错: "+e.toString());
}
return   contents;
}


这段分业代码是针对ORACLE数据库的,现在麻烦高手帮我改下查询的SQL语句,改成从ACCESS里取数据的SQL

------解决方案--------------------
不管
------解决方案--------------------
你把表结构 和 sql语句输出贴上来吧
------解决方案--------------------
哈哈,Access不熟悉。。
------解决方案--------------------
汗。。不是吧


 你要什么样的。。你sql语句。。说下。


还有就是表结构