⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orderinfo.java

📁 一个完整的网上书店
💻 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 + -