booktypedao.java

来自「一套网上书店系统采用JAVABEAN+SERVLET+JSP」· Java 代码 · 共 54 行

JAVA
54
字号
package cn.dang.dao;

import ghy_db.DB_operate_interface;

import java.util.ArrayList;
import java.util.List;

import cn.dang.entity.BookType;

public class BookTypeDAO {
	DB_operate_interface dbRef;
	public BookTypeDAO(DB_operate_interface dbRef){
		super();
		this.dbRef=dbRef;
	}
	
	/**
	 * @param String sql 查询二级类型所需的SQL语句
	 * @return
	 * @throws Throwable
	 */
	public List<BookType> querySmallType(String sql) throws Throwable{
		//从DB通用类中调用query方法获得数据
		List list=dbRef.query(sql);
		//创建放置BookType的容器
		List<BookType> bookTypes=new ArrayList<BookType>();
		//遍历循环出bookType并重新封装到容器中
		for(int i=0;i<list.size();i++){
			String[] small=(String[])list.get(i);
			BookType bookType=new BookType();
			bookType.setId(Integer.parseInt(small[0]));
			bookType.setTypeName(small[1]);
			bookType.setOid(Integer.parseInt(small[2]));
			bookTypes.add(bookType);
		}
		return bookTypes;
	}
	public BookType querySmallTypeInfo(String sql) throws Throwable{
		//从DB通用类中调用query方法获得数据
		List list=dbRef.query(sql);
		BookType bookType=new BookType();
		if(list.size()>0){
			String[] small=(String[])list.get(0);		
			bookType.setId(Integer.parseInt(small[0]));
			bookType.setTypeName(small[1]);
			bookType.setOid(Integer.parseInt(small[2]));
		}
		return bookType;
	}
	public void UpdateBookTypeInfo(String sql,ArrayList values_list) throws Throwable{
		dbRef.update(sql, values_list);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?