首页>代码>java开发贵美商城系统项目源码下载>/新建文件夹/1/GuiMeiShopping/src/com/dao/BigClassDao.java
package com.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.entity.BigClass;
import com.util.DBUtil;

public class BigClassDao {
	/**
	 * 添加
	 * @param b_name
	 * @return k
	 */
	public static int add(String b_name){
		String sql="insert into bigclass(b_name) values(?)";
		Object obj[]={b_name};
		int k=DBUtil.Update(sql, obj);
		return k;
	}
	/**
	 * 根据编号修改分类名称
	 * @param b_name
	 * @param b_id
	 * @return
	 */
	public static int update(String b_name,String b_id){
		String sql="update bigclass set b_name=? where b_id=?";
		Object obj[]={b_name,b_id};
		int k=DBUtil.Update(sql, obj);
		return k;
	}
	/**
	 * 根据编号删除大分类信息
	 * @param b_id
	 * @return
	 */
	public static int delete(String b_id){
		String sql="delete from bigclass where b_id=?";
		Object obj[]={b_id};
		int k=DBUtil.Update(sql, obj);
		return k;
	}
	/**
	 * 判断输入的分类名称是否已存在
	 * @param bname
	 * @return boolean
	 */
	public static boolean getBname(String bname){
		String sql="select * from bigClass where b_name=?";
		Object obj[]={bname};
		ResultSet res=DBUtil.query(sql, obj);
		try {
			if (res.next()) {
				return true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return false;
	}
	/**
	 * 查询分类总条数
	 * @return count
	 */
	public static int bigClassCount(){
		int count=0;
		String sql="select count(*) from bigClass";
		Object obj[]={};
		ResultSet res=DBUtil.query(sql, obj);
		try {
			if (res.next()) {
				count=res.getInt(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return count;
	}
	/**
	 * 查询所有大分类信息 分页查询
	 * @return list集合
	 */
	public static List<BigClass> queryAll(Integer pageStart,Integer pageSize){
		String sql="select * from bigClass limit ?,?";
		Object obj[]={pageStart,pageSize};
		ResultSet res=DBUtil.query(sql, obj);
		List<BigClass> list=new ArrayList<BigClass>();
		try {
			while(res.next()){
				BigClass bi=new	BigClass(res.getInt(1), res.getString(2));
				list.add(bi);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return list;
	}
	/**
	 * 查询所有大分类信息
	 * @return list集合
	 */
	public static List<BigClass> queryAll(){
		String sql="select * from bigClass";
		Object obj[]={};
		ResultSet res=DBUtil.query(sql, obj);
		List<BigClass> list=new ArrayList<BigClass>();
		try {
			while(res.next()){
				BigClass bi=new	BigClass(res.getInt(1), res.getString(2));
				list.add(bi);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return list;
	}
	/**
	 * 根据名称查询大分类编号
	 * @return b_id
	 */
	public static String queryId(String b_name){
		String sql="select b_id from bigClass where b_name=?";
		Object obj[]={b_name};
		ResultSet res=DBUtil.query(sql, obj);
		String b_id=null;
		try {
			if(res.next()){
				b_id=res.getString(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return b_id;
	}
	/**
	 * 根据编号查询大分类名称
	 * @return b_name
	 */
	public static String queryName(String b_id){
		String sql="select b_name from bigClass where b_id=?";
		Object obj[]={b_id};
		ResultSet res=DBUtil.query(sql, obj);
		String b_name=null;
		try {
			if(res.next()){
				b_name=res.getString(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			DBUtil.close();
		}
		return b_name;
	}
}
最近下载更多
小逸夜  LV4 2022年12月29日
testuser1234567  LV24 2022年6月15日
微信网友_5934504231161856  LV1 2022年4月27日
lzlzyw  LV14 2022年3月25日
linxi1134  LV4 2022年1月5日
314997zf  LV4 2021年12月23日
lwp011  LV27 2021年11月5日
南风入弦  LV5 2021年6月26日
wanglinddad  LV54 2021年4月22日
那个米龙  LV8 2020年12月8日
最近浏览更多
15103432984  LV2 3月17日
try8023  LV18 1月16日
ncyhhh  LV1 2023年11月26日
蹇金金  LV7 2023年11月6日
abandan  LV4 2023年11月6日
heqian  LV16 2023年10月31日
nimi777 2023年9月12日
暂无贡献等级
SDLFJL  LV6 2023年7月23日
dw45dw  LV1 2023年6月24日
xyzzuidaima  LV3 2023年6月13日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友