• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

推出weblogic+oracle 分页

发布: 2007-7-01 18:47 | 作者: admin | 来源: | 查看: 16次 | 进入软件测试论坛讨论

领测软件测试网 import java.sql.*;
import java.util.*;
import weblogic.db.jdbc.*;

public class bandlistBean {
  private String driver;
  private String dbURL;
  private Bean2 b=new Bean2();
  
public bandlistBean(){
   globalBean globalstr = new globalBean();
   driver = globalstr.getDBDriver();
   dbURL = globalstr.getDBURL();
}

public String getKey(String href,int recordPerPage,int startRecord) {
  Connection conn = null;
  QueryDataSet dSet = null;
  String shortkeystr ="";
  try{
   Class.forName(driver).newInstance();
   conn=DriverManager.getConnection(dbURL);
   String countsql = "Select count(*) as count from TABLE where yijlmbm=1 and riq=to_char(sysdate,@#yyyymmdd@#)";
   dSet = new QueryDataSet(conn,countsql);
   dSet.fetchRecords();
   Record countRecord = dSet.getRecord(0);
   int dSetAllSize = countRecord.getValue("count").asInt();

   int pages = dSetAllSize/recordPerPage;
   if(dSetAllSize%recordPerPage !=0) pages++;
   for(int i=0;i<pages;i++) {
   if(startRecord == i*recordPerPage) {
    shortkeystr = shortkeystr + "<Font size=+1>";   //    被选中页数字字体增大
    shortkeystr = shortkeystr + href + "?startRecord=" + Integer.toString(i*recordPerPage) + ">";
    shortkeystr = shortkeystr + Integer.toString(i+1) + "</a></Font>" + "\n";
     }else {
   shortkeystr = shortkeystr + href + "?startRecord=" + Integer.toString(i*recordPerPage) + ">";
   shortkeystr = shortkeystr + Integer.toString(i+1) + "</a>" + "\n";
   }
   }
  }catch(Exception e) { System.out.println("Exception:"+e);}
    finally{
    if (dSet!= null) try {dSet.close();}catch(Exception e){}
    if (conn!= null) try {conn.close();}catch(Exception e){}
    }
    return shortkeystr;
    }

public String getYjlmList(String href1,String href2,String href3,int recordPerPage,int startRecord) {
     String newsstr = "";
     Connection conn = null;
     QueryDataSet dSet = null;
     String zy="";
      try {
      Class.forName(driver).newInstance();
      conn=DriverManager.getConnection(dbURL);
      String sqlstr = "Select xinxibm,biaot,weight from xinx where yijlmbm=1 and riq=to_char(sysdate,@#yyyymmdd@#) order by xinxibm desc";
      dSet = new QueryDataSet(conn,sqlstr);
       dSet.fetchRecords(startRecord,recordPerPage);
      int dSetSize = dSet.size();

      for(int x=0;x<dSetSize;x++){
      Record curRecord = dSet.getRecord(x);
      String xinxibm = new Integer(curRecord.getValue("xinxibm").asInt()).toString().trim();
      String biaot = b.x2u(curRecord.getValue("biaot").asString().trim());
      String weight = new Integer(curRecord.getValue("weight").asInt()).toString().trim();
      if(weight.compareTo("1")==0){
          zy="重要新闻";
          }else{
        zy="普通新闻";
        }
     newsstr = newsstr + "<tr><td bgcolor=@##E1DFD2@#>" + href1 + "?Item=";
     newsstr = newsstr + xinxibm + ">" ;
     newsstr = newsstr + biaot + "</a></td>";
     newsstr = newsstr + "<td bgcolor=@##E1DFD2@#>" + href2 + "?Item1=";
     newsstr = newsstr + xinxibm +">普通新闻</a>";
     newsstr = newsstr + "  " + href3 + "?Item1=";
     newsstr = newsstr + xinxibm + ">头条新闻</a></td>";
     newsstr = newsstr + "<td bgcolor=@##E1DFD2@# >" + zy + "</td></tr>";
      }
      dSet.close();
      conn.close();
      }catch(Exception e) {}
      finally{
      if (dSet!= null) try {dSet.close();}catch(Exception e){}
      if (conn!= null) try {conn.close();}catch(Exception e){}
      }
      return newsstr;
   }

}

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网