GateWayFactory.java
上传用户:toby834
上传日期:2013-10-21
资源大小:2613k
文件大小:2k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. package net.acai.forum;
  2. /**
  3.  * Title:        清清网络
  4.  * Description:
  5.  * Copyright:    Copyright (c) 2002
  6.  * Company:      www.SuperSpace.com
  7.  * @author:       SuperSpace
  8.  * @version 1.0
  9.  */
  10. import net.acai.database.*;
  11. import net.acai.forum.GateWayNotFoundException;
  12. import java.sql.ResultSet;
  13. import java.util.Vector;
  14. import javax.servlet.http.*;
  15. import net.acai.util.*;
  16. public class GateWayFactory{
  17. public static Vector getGateWays() throws GateWayNotFoundException{
  18. try{
  19. DBConnect dbc=new DBConnect("select * from bbs.class order by id");
  20. ResultSet rs=dbc.executeQuery();
  21. Vector gateWayVector=new Vector();
  22. int gateWayID;
  23. String gateWayName;
  24. GateWay gateWay;
  25. while(rs.next()){
  26. gateWayID=rs.getInt(1);
  27. gateWayName=rs.getString(2);
  28. gateWay=new GateWay(gateWayID,gateWayName);
  29. gateWayVector.add(gateWay);
  30. }
  31. dbc.close();
  32. return gateWayVector;
  33. }
  34. catch(Exception e){
  35. throw new GateWayNotFoundException();
  36. }
  37. }
  38. public static GateWay getGateWay(HttpServletRequest request) throws Exception{
  39. int ID;
  40. try{
  41. ID=ParamUtil.getInt(request,"id");
  42. }
  43. catch(Exception e){
  44. throw new Exception("请您选择您要排序的分类的ID");
  45. }
  46. DBConnect dbc=new DBConnect();
  47. String sql="select id,class from bbs.class where id="+ID;
  48. ResultSet rs=dbc.executeQuery(sql);
  49. if(!rs.next())
  50. throw new Exception("没有找到相应的论坛分类。");
  51. //rs.next();
  52. GateWay gateWay=new GateWay(rs.getInt(1),rs.getString(2));
  53. dbc.close();
  54. return gateWay;
  55. }
  56. }