?? orderinfo.java
字號:
package com.ascenttech.ebookstore.bean;
import java.sql.*;
import com.ascenttech.ebookstore.util.DataAccess;
public class Orderinfo {
//data
private int orderId;
private String title;
private String custname;
private String address;
private String user;
private java.sql.Date date;
private String booklist;
private float price;
public Orderinfo() {
}
//getXxx()
public String getTitle(){return this.title;}
public String getCustname(){return this.custname;}
public String getUser(){return this.user;}
public String getAddress(){return this.address;}
public float getPrice(){return this.price;}
public String getBooklist(){return this.booklist;}
public java.sql.Date getDate(){return this.date;}
//setXxx()
public void setTitle(String title){this.title = title;}
public void setCustomer(String custname){this.custname=custname;}
public void setUser(String user){this.user = user;}
public void setAddress(String addr){this.address=addr;}
public void setPrice(float price){this.price = price;}
public void setDate(java.sql.Date date){this.date = date;}
public void setBooklist(String booklist){this.booklist = booklist;}
public void saveOrder() throws Exception {
Connection con = DataAccess.getConnection();
String sqlStr = "insert into ebs_order(title, custname,address,user,date,booklist, price)"
+ "values('"+this.getTitle()+"',"
+ "'"+this.getCustname()+"',"
+ "'"+this.getAddress()+"',"
+ "'"+this.getUser()+"',"
+ "'"+this.getDate()+"',"
+ "'"+this.getBooklist() +"',"
+ this.getPrice()+")";
Statement stmt = con.createStatement();
stmt.executeUpdate(sqlStr);
stmt.close();
con.close();
}
public int getLastInsertId() throws SQLException {
int last_oid=0;
Connection con = DataAccess.getConnection();
String sqlStr = "select count(*) as count from ebs_order";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(sqlStr);
while (rs.next()){
last_oid = rs.getInt(1);
}
rs.close();
stmt.close();
con.close();
return last_oid;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -