📄 buybook.java
字号:
import java.sql.*;
public class BuyBook
{
long id=0;
String order_number,book_name;
Connection con;
Statement sql;
ResultSet rs;
public BuyBook()
{ try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(ClassNotFoundException e){}
}
public void setId(long n)
{
id=n;
}
public long getId()
{
return id;
}
public void setBook_name(String name)
{
book_name=name;
}
public String getBook_name()
{
return book_name;
}
public void setOrder_number(String number)
{
order_number=number;
}
public String getOrder_number()
{
return order_number;
}
public StringBuffer getMessageBybook_id()
{
StringBuffer buffer=new StringBuffer();
try
{ con=DriverManager.getConnection("jdbc:odbc:shop","","");
sql=con.createStatement();
String condition="SELECT * FROM book WHERE id ="+id;
rs=sql.executeQuery(condition);
buffer.append("<Table Border>");
buffer.append("<TR>");
buffer.append("<TH width=50>"+"<Font size=3>"+"id"+"</Font>");
buffer.append("<TH width=50>"+"<Font size=3>"+"订购号"+"</Font>");
buffer.append("<TH width=70>"+"<Font size=3>"+"书名"+"</Font>");
buffer.append("<TH width=60>"+"<Font size=3>"+"作者"+"</Font>");
buffer.append("<TH width=60>"+"<Font size=3>"+"出版社"+"</Font>");
buffer.append("<TH width=50>"+"<Font size=3>"+"出版时间"+"</Font>");
buffer.append("<TH width=20>"+"<Font size=3>"+"价钱"+"</Font>");
buffer.append("<TH width=50>"+"<Font size=3>"+"分类"+"</Font>");
buffer.append("</TR>");
while(rs.next())
{
order_number=rs.getString(2);
book_name=rs.getString(3);
String 作者=rs.getString(4);
String 出版社=rs.getString(5);
String 时间=rs.getString(6);
String 价格=rs.getString("price");
String 分类=rs.getString("category");
buffer.append("<TR>");
buffer.append("<TD>"+"<Font size=3>"+rs.getLong(1)+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+order_number+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+book_name+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+作者+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+出版社+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+时间+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+价格+"</Font>");
buffer.append("<TD>"+"<Font size=3>"+分类+"</Font>");
buffer.append("</TR>");
}
buffer.append("</Table>");
con.close();
return buffer;
}catch(SQLException e)
{
return buffer;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -