op_bookclass.java~4~
上传用户:tanyanyong
上传日期:2013-06-23
资源大小:1355k
文件大小:3k
源码类别:

电子政务应用

开发平台:

MultiPlatform

  1. package bookshop.run;
  2. /**
  3.  * <p>Title: </p>
  4.  * <p>Description: </p>
  5.  * <p>Copyright: Copyright (c) 2004</p>
  6.  * <p>Company: </p>
  7.  * @author not attributable
  8.  * @version 1.0
  9.  */
  10. import java.util.*;
  11. import bookshop.util.*;
  12. import bookshop.book.*;
  13. import java.sql.*;
  14. import java.lang.String;
  15. import javax.servlet.http.HttpServletRequest;
  16. public class op_bookclass extends DataBase{
  17.   public op_bookclass() {
  18.   }
  19.   private bookclass bookclass = new bookclass(); //新的图书分类
  20.   private javax.servlet.http.HttpServletRequest request; //建立页面请求
  21.   private Vector classlist; //图书类别向量数组
  22.   public Vector getClasslist() {
  23.         return classlist;
  24.           }
  25.   public String getBookClassSql() {
  26.                   sqlStr = "select id,classname from bookclass order by id";
  27.                   return sqlStr;
  28.           }
  29.   public boolean seachBookClass() throws Exception {
  30.                   int id = 0;
  31.                   String classname = "";
  32.                   int rscount = 0;
  33.                   try {
  34.                     DataBase db = new DataBase();
  35.                    db.connect();
  36.                    stmt = db.conn.createStatement ();
  37.                           rs = stmt.executeQuery(getBookClassSql());
  38.                           rscount = stmt.getMaxRows();
  39.                           classlist = new Vector(rscount+1);
  40.                           classlist.clear();
  41.                           while (rs.next()){
  42.                                   id = rs.getInt("id");
  43.                                   classname = rs.getString("classname");
  44.                                   bookclass bc = new bookclass(id,classname);
  45.                                   classlist.addElement(bc);
  46.                           }
  47.                           rs.close();
  48.                           return true;
  49.                   }
  50.                   catch (SQLException sqle){
  51.                           System.out.println(sqle);
  52.               return false;
  53.                   }
  54.           }
  55.           public boolean getRequest(javax.servlet.http.HttpServletRequest newrequest) {
  56.                          boolean flag = false;
  57.                         try{
  58.                                  request = newrequest;
  59.                                  String bookclassname = request.getParameter("bookclassname");
  60.                                  if (bookclassname==null || bookclassname.equals(""))
  61.                                  {
  62.                                          bookclassname = "";
  63.                                          flag = false;
  64.                                  }
  65.                                  bookclass.setClassName(bookclassname);
  66.                                 return true;
  67.                         }catch (Exception e){
  68.                           return false;
  69.                         }
  70.                  }
  71.   };