📄 gatewayfactory.java
字号:
package com.bcxy.bbs.forum;
/**
* Title:
* Description:
* Copyright:
* Company: www.liyunet.com
*
* @author lishujiang
* @version 1.0
*/
import java.util.Vector;
import javax.servlet.http.HttpServletRequest;
import com.bcxy.bbs.util.ParamUtil;
import com.bcxy.cache.CacheManager;
import com.bcxy.conf.ENV;
import com.bcxy.db.SqlQuery;
public class GateWayFactory {
public static Vector getGateWays() throws GateWayNotFoundException {
SqlQuery rs = new SqlQuery();
try {
// DBConnect dbc=new DBConnect("select * from class order by id");
// ResultSet rs=dbc.executeQuery();
rs.doQuery("select id,class from class order by id");
Vector gateWayVector = new Vector();
int gateWayID;
String gateWayName;
GateWay gateWay = null;
while (rs.next()) {
gateWayID = rs.getInt(1);
gateWay = (GateWay)CacheManager.getCache(ENV.GATEWAY).get(String.valueOf(gateWayID));
if(gateWay==null){
gateWayName = rs.getString(2);
gateWay = new GateWay(gateWayID, gateWayName);
CacheManager.getCache(ENV.GATEWAY).put(String.valueOf(gateWayID),gateWay);
}
gateWayVector.add(gateWay);
}
// dbc.close();
return gateWayVector;
} catch (Exception e) {
throw new GateWayNotFoundException();
}
}
public static GateWay getGateWay(HttpServletRequest request)
throws Exception {
int ID;
try {
ID = ParamUtil.getInt(request, "id");
} catch (Exception e) {
throw new Exception("请您选择您要排序的分类的ID");
}
String sql = "select id,class from class where id=" + ID;
SqlQuery rs = new SqlQuery(sql);
if (!rs.next())
throw new Exception("没有找到相应的论坛分类。");
//rs.next();
GateWay gateWay = new GateWay(rs.getInt(1), rs.getString(2));
return gateWay;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -