op_bookclass.java~3~
上传用户: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_bookclass extends DataBase{
  15.   public op_bookclass() {
  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.                     DataBase db = new DataBase();
  31.                    db.connect();
  32.                    stmt = db.conn.createStatement ();
  33.                           rs = stmt.executeQuery(getBookClassSql());
  34.                           rscount = stmt.getMaxRows();
  35.                           classlist = new Vector(rscount+1);
  36.                           classlist.clear();
  37.                           while (rs.next()){
  38.                                   id = rs.getInt("id");
  39.                                   classname = rs.getString("classname");
  40.                                   bookclass bc = new bookclass(id,classname);
  41.                                   classlist.addElement(bc);
  42.                           }
  43.                           rs.close();
  44.                           return true;
  45.                   }
  46.                   catch (SQLException sqle){
  47.                           System.out.println(sqle);
  48.               return false;
  49.                   }
  50.           }
  51.   };