book.java

来自「实例大全」· Java 代码 · 共 66 行

JAVA
66
字号
package shopping;
import java.sql.*;
import opendb.opendb;
public class Book
{
	String bookname;
	String author;
	String bookid;
	float price;
	int quantity;

	public Book(String proid)
	{
		opendb mydb=new opendb();
		String sql="select BookName,Author,Price form book where bookid='"+proid+"'";
		System.out.println(sql);
		ResultSet rs=mydb.executeQuery(sql);
		try
		{
			rs.next();
			bookname=rs.getString("BookName");
			System.out.println(bookname);
			bookid=proid;
			author=rs.getString("Author");
			System.out.println(author);
			price=(new float (rs.getString("Price"))).flostValue();
			System.out.println(price);	
			quantity=1;
			rs.close();
		}
		catch (SQLException e)
		{
			System.out.println("Database Error!");
		}
	}

	public String getbookname()
	{
		return bookname;
	}

	public String getauthor()
	{
		return author;
	}

	public String getbookid()
	{
		return bookid;
	}

	public float getprice()
	{
		return price;
	}

	public void setQuantity(int q)
	{
		quantity=q;
	}

	public int getQuantity()
	{
		return quantity;
	}
};

⌨️ 快捷键说明

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