⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewcategory.java

📁 基于WEB的商品管理系统
💻 JAVA
字号:
/*
 * ViewCategory.java
 *
 * Created on 2007年10月25日, 下午3:37
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.me.product;

import java.sql.*;
import java.util.*;
import java.io.*;
import org.me.util.*;

/**
 *
 * //查看所有的商品分类
 */
public class ViewCategory {
    
    /** Creates a new instance of ViewCategory */
   private Connection con;
	//公共方法,获得数据库的连接
	public ViewCategory()
	{
		this.con=DataBaseConnection.getConnection();
	}
	/**
	 *返回商品的所有分类,返回的Collection中包含Category值对象。
	 */
	public Collection getAllCategory()throws Exception
	{
		Statement stmt=con.createStatement();
		ResultSet rst=stmt.executeQuery("select * from category");
		Collection ret=new ArrayList();
		while(rst.next())
		{
			Category temp=new Category();
			temp.setCategoryId(rst.getString("catid"));
			temp.setDescription(rst.getString("descn"));
			temp.setName(rst.getString("name"));
			ret.add(temp);
		}
		//关闭连接,rst和stmt将自动关闭。
		con.close();
		return ret;
	}
}

⌨️ 快捷键说明

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