op_bookclass.java~6~
上传用户:tanyanyong
上传日期:2013-06-23
资源大小:1355k
文件大小:4k
源码类别:
电子政务应用
开发平台:
MultiPlatform
- package bookshop.run;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2004</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import java.util.*;
- import bookshop.util.*;
- import bookshop.book.*;
- import java.sql.*;
- import java.lang.String;
- import javax.servlet.http.HttpServletRequest;
- public class op_bookclass extends DataBase{
- public op_bookclass() {
- }
- private bookclass bookclass = new bookclass(); //新的图书分类
- private javax.servlet.http.HttpServletRequest request; //建立页面请求
- private Vector classlist; //图书类别向量数组
- public Vector getClasslist() {
- return classlist;
- }
- public String getBookClassSql() {
- sqlStr = "select id,classname from bookclass order by id";
- return sqlStr;
- }
- public boolean seachBookClass() throws Exception {
- int id = 0;
- String classname = "";
- int rscount = 0;
- try {
- DataBase db = new DataBase();
- db.connect();
- stmt = db.conn.createStatement ();
- rs = stmt.executeQuery(getBookClassSql());
- rscount = stmt.getMaxRows();
- classlist = new Vector(rscount+1);
- classlist.clear();
- while (rs.next()){
- id = rs.getInt("id");
- classname = rs.getString("classname");
- bookclass bc = new bookclass(id,classname);
- classlist.addElement(bc);
- }
- rs.close();
- return true;
- }
- catch (SQLException sqle){
- System.out.println(sqle);
- return false;
- }
- }
- public boolean getRequest(javax.servlet.http.HttpServletRequest newrequest) {
- boolean flag = false;
- try{
- request = newrequest;
- String bookclassname = request.getParameter("bookclassname");
- if (bookclassname==null || bookclassname.equals(""))
- {
- bookclassname = "";
- flag = false;
- }
- bookclass.setClassName(bookclassname);
- return true;
- }catch (Exception e){
- return false;
- }
- }
- public boolean insert() throws Exception {
- sqlStr = "insert into bookclass (classname) values ('";
- sqlStr = sqlStr + dataFormat.toSql(bookclass.getClassName()) + "')";
- try
- { System.out.print(sqlStr);
- DataBase db = new DataBase();
- db.connect();
- stmt =db.conn.createStatement ();
- stmt.execute(sqlStr);
- return true;
- }
- catch (SQLException sqle)
- { System.out.print(sqle.getMessage());
- return false;
- }
- }
- public boolean delete( int aid ) throws Exception {
- sqlStr = "delete from bookclass where id = " + aid ;
- try
- { DataBase db = new DataBase();
- db.connect();
- stmt =db.conn.createStatement ();
- stmt.execute(sqlStr);
- return true;
- }
- catch (SQLException e)
- {
- System.out.println(e);
- return false;
- }
- }
- };