网上书店

源代码在线查看: catebean.java

软件大小: 72 K
上传用户: wuqiweipp
关键词:
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.bitc.store;

				//定义Bean所属的套件

				

				//定义使用的套件

				import java.sql.*;

				

				public class CateBean

				{

					//与资料库连结有关的Bean属性

					private Connection con = null;

					private Statement stmt = null;

					private ResultSet CateRs = null;

				

					public CateBean()  //建构子

					{		

					}

				

					//起始建立ResultSet物件

					public void InitCateRs(Connection con)

					{

						try{

							if (this.con != con)

								this.con = con;									

							stmt = con.createStatement(

									ResultSet.TYPE_SCROLL_INSENSITIVE,

									ResultSet.CONCUR_READ_ONLY);

							//建立Statement物件	

							

							CateRs = stmt.executeQuery

								 ("SELECT * FROM Category");

							//执行SQL叙述

						}

						catch(SQLException sex)

						{

							System.out.println(sex.toString());

						}		

					}

				

					//关闭ResultSet物件与Statement物件

					public void CloseCateRs()

					{ 

						try{

							if(CateRs != null)

							{

								CateRs.close();

								CateRs = null;

							}

							

							if(stmt != null)

							{

								stmt.close();

								stmt = null;

							}

						}

						catch(SQLException sex)

						{

							System.out.println(sex.toString());

						}

					}

				

					//移至下一笔

					public boolean next()

					{ 

						boolean result = false;

				

						try{

							result = CateRs.next();

							//移至下一笔

						}

						catch(SQLException sex)

						{

							System.out.println(sex.toString());

						}		

						return result;

					}

					

					//取得记录集中的Category栏

					public String getCategory()

					{ 

						String result = null;

				

						try{

							result = CateRs.getString("Category");

						}

						catch(SQLException sex)

						{

							System.out.println(sex.toString());

						}		

						return result;

					}

				

					//取得记录集中的CateID栏

					public String getCateID()

					{ 

						String result = null;

				

						try{

							result = CateRs.getString("ID");

						}

						catch(SQLException sex)

						{

							System.out.println(sex.toString());

						}		

						return result;

					}

				}

							

相关资源