personalinformationbean.java

来自「《JSP程序设计实用教程》-梁建武-源代码-4567.rar」· Java 代码 · 共 42 行

JAVA
42
字号
package com.saleSystem;
import java.util.*;
import java.io.*;
import java.sql.*;
import com.saleSystem.util.*;

/**
 *PersonalImformationBean包含和Personal表相关的操作
 */
public class PersonalInformationBean
{
	private Connection con;
	//构造方法,获得数据库的连接。
	public PersonalInformationBean()
	{
		this.con=DataBaseConnection.getConnection();
	}
	/**
	 *搜索所有的上销售员信息。
	 *返回由Personal值对象组成的Collection
	 */
	public Collection getAllPersonal()throws Exception
	{
		Statement stmt=con.createStatement();
		ResultSet rst=stmt.executeQuery("select * from Personal");
		Collection ret=new ArrayList();
		while(rst.next())
		{
			Personal temp=new Personal();
			temp.setPersonalCode(rst.getString("personalCode"));
		    temp.setName(rst.getString("name"));
	        temp.setSex(rst.getString("sex"));
	        temp.setAddress(rst.getString("address"));
            temp.setTelephone(rst.getString("telephone"));
			
			ret.add(temp);
		}
		con.close();
		return ret;
	}
	
}

⌨️ 快捷键说明

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