op_bookclass.java~1~
上传用户:sxlinghang
上传日期:2022-07-20
资源大小:1405k
文件大小:2k
源码类别:

数据库编程

开发平台:

Java

  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. public class op_book extends DataBase{
  15.   public op_book() {
  16.   }
  17.   private Vector classlist; //图书类别向量数组
  18.   public Vector getClasslist() {
  19.         return classlist;
  20.           }
  21.   public String getBookClassSql() {
  22.                   sqlStr = "select id,classname from bookclass order by id";
  23.                   return sqlStr;
  24.           }
  25.   public boolean seachBookClass() throws Exception {
  26.                   int id = 0;
  27.                   String classname = "";
  28.                   int rscount = 0;
  29.                   try {
  30.                           rs = stmt.executeQuery(getBookClassSql());
  31.                           rscount = stmt.getMaxRows();
  32.                           classlist = new Vector(rscount+1);
  33.                           classlist.clear();
  34.                           while (rs.next()){
  35.                                   id = rs.getInt("id");
  36.                                   classname = rs.getString("classname");
  37.                                   bookclass bc = new bookclass(id,classname);
  38.                                   classlist.addElement(bc);
  39.                           }
  40.                           rs.close();
  41.                           return true;
  42.                   }
  43.                   catch (SQLException sqle){
  44.                           System.out.println(sqle);
  45.               return false;
  46.                   }
  47.           }
  48.   };