book.java

来自「利用JSP来实现网站的各种功能」· Java 代码 · 共 55 行

JAVA
55
字号
package bookshop;

import java.sql.*;
import bookshop.*;

public class Book {
	protected String isbn;
	protected String title;
	protected float price;
	protected int buynum;
	
	public Book(String _isbn, int _buynum){
		try{
			DBSQLManager dbsm = new DBSQLManager();
			String sql="SELECT ISBN,TITLE,PRICE FROM bookinfo WHERE ISBN='"+_isbn+"'";
			dbsm.setSqlStr(sql);
			dbsm.executeQuery();
			ResultSet rs = dbsm.getRs();
			rs.next();
			isbn = _isbn;
			title = rs.getString("TITLE");
			price = rs.getFloat("PRICE");
			buynum = _buynum;
			dbsm.close();
		}
		catch (Exception e){
			System.out.println(e.toString());
		}
	}
	public void setIsbn(String newIsbn){
		this.isbn = newIsbn;
	}
	public String getIsbn(){
		return isbn;
	}
	public void setTitle(String newTitle){
		this.title = newTitle;
	}
	public String getTitle(){
		return title;
	}
	public void setPrice(float newPrice){
		this.price = newPrice;
	}
	public float getPrice(){
		return price;
	}
	public void setBuynum(int newBuynum){
		this.buynum = newBuynum;
	}
	public int getBuynum(){
		return buynum;
	}
}

⌨️ 快捷键说明

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