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;
}
}
