📄 product.java
字号:
package shopping.objectType;
import java.sql.*;
import java.io.*;
import shopping.connectionDB;
public class Product implements Serializable{
private String productId;
private String productName;
private String productDesc;
private Double productPrice;
private connectionDB connectiondb=new connectionDB();
private Statement statement;
public void setProductId(String productId){
this.productId=productId;
}
public String getProductId(){
return productId;
}
public String getproductName(){
return productName;
}
public String getproductDesc(){
return productDesc;
}
public Double getProductPrice(){
return productPrice;
}
public void getProductParameter(){
try{
statement=connectiondb.setDBConnection();
String sql="select * from products where productid='"+productId+"'";
ResultSet results=statement.executeQuery(sql);
while(results.next())
{
productName=results.getString(2);
productDesc=results.getString(3);
productPrice=new Double(results.getInt(4));
}
}catch(Exception e)
{
System.out.println("get product informatio is error");
}
}
public Product (String productId)
{
this.setProductId(productId);
this.getProductParameter();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -