⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gatewayfactory.java

📁 一个用jsp写的完整的论坛源代码
💻 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 org.apache.log4j.Logger;

import com.bcxy.bbs.util.BBSConst;
import com.bcxy.bbs.util.ParamUtil;
import com.bcxy.cache.CacheManager;
import com.bcxy.conf.ENV;
import com.bcxy.db.JdbcWrapper;

public class GateWayFactory {

	private static Logger log = Logger.getLogger(GateWayFactory.class);

	public static Vector getGateWays() throws GateWayNotFoundException {
		Vector gateWayVector = new Vector();
		JdbcWrapper jw = new JdbcWrapper();
		try {
			jw.executeQuery("select id,class from " + BBSConst.TABLE_CLASS
					+ " order by id");
			int gateWayID;
			String gateWayName;
			GateWay gateWay = null;
			while (jw.next()) {
				gateWayID = jw.getInt(1);
				gateWay = (GateWay) CacheManager.getCache(ENV.GATEWAY).get(
						String.valueOf(gateWayID));
				if (gateWay == null) {
					gateWayName = jw.getString(2);
					gateWay = new GateWay(gateWayID, gateWayName);
					CacheManager.getCache(ENV.GATEWAY).put(
							String.valueOf(gateWayID), gateWay);
				}
				gateWayVector.add(gateWay);
			}
			return gateWayVector;
		} catch (Exception e) {
			log.error("取得论坛分类出错", e);
			throw new GateWayNotFoundException();
		} finally {
			jw.close();
		}

	}

	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 " + BBSConst.TABLE_CLASS
				+ " where id=" + ID;
		JdbcWrapper jw = new JdbcWrapper(sql);
		if (!jw.next()) {
			throw new Exception("没有找到相应的论坛分类。");
		}
		return new GateWay(jw.getInt(1), jw.getString(2));
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -