jsp购物车源码,解压密码的要说明密码www.kj.com
源代码在线查看: bookbean.java
/*
* @(#)BookBean.java 1.0 06/03/03
*
* Copyright 2006 林刘炜
*/
package beans;
import java.sql.*;
/**
* 该Bean利用 DBOperation Bean连接数据库
* 读取数据库中,图书的基本信息
*
* @version 1.0
* @author 林刘炜
*/
public class BookBean
{
private String id = null; //图书id编号
private String name = null; //图书名称
private String author = null;// 图书的作者
private String publisher = null;//图书的出版社
private float price =0f;// 图书价格
private String introduce = null;//图书的介绍
/**
* 构造一个新的BookBean
*/
public BookBean(){
}
/**
* 根据图书的id编号,给图书的其他信息赋值
*
* @param id String类型的图书ID编号
*/
public void setBookInfo(String isbn){
id = null;
name = null;
author = null;
publisher = null;
price = 0f;
introduce = null;
DBOperation database = new DBOperation();
try{
ResultSet rst = database.executeSQL(" select * from bookInfo where ISBN='"+isbn+"' ");
if( rst.next() ){
id = rst.getString("ISBN");
name = rst.getString("name");
author = rst.getString("author");
publisher = rst.getString("publisher");
price = rst.getFloat("price");
introduce = rst.getString("introduce");
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
database.closeDatabase();
}catch(SQLException e){
e.printStackTrace();
}
}
}
/**
* 获取图书的编号
*
* @return String
*/
public String getBookID(){
return id;
}
/**
* 获取图书的名称
*
* @return String
*/
public String getBookName(){
return name;
}
/**
*方法说明: 获取图书的作者
*
* @return String
*/
public String getBookAuthor(){
return author;
}
/**
* 获取图书的出版社信息
*
* @return String
*/
public String getBookPublisher(){
return publisher;
}
/**
* 获取图书的价格
*
* @return String
*/
public float getBookPrice(){
return price;
}
/**
* 获取图书的介绍信息
*
* @return String
*/
public String getBookIntroduce(){
return introduce;
}
/**
* 将Bean作为一个application进行测试用
*/
public static void main(String[] args){
BookBean book = new BookBean();
book.setBookInfo("1");
System.out.println (book.getBookID());
System.out.println (book.getBookName());
System.out.println (book.getBookAuthor());
System.out.println (book.getBookPublisher());
System.out.println (book.getBookPrice());
System.out.println (book.getBookIntroduce());
}
}