git init
parent
0e433b077d
commit
47a5fac051
|
@ -1,5 +1,7 @@
|
||||||
package com.bwie.dao;
|
package com.bwie.dao;
|
||||||
|
|
||||||
|
import com.bwie.pojo.Bill;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
public class BillDao {
|
public class BillDao {
|
||||||
|
@ -11,11 +13,12 @@ public class BillDao {
|
||||||
|
|
||||||
}
|
}
|
||||||
// 添加数据到表
|
// 添加数据到表
|
||||||
public void add(String someColumn) {
|
public void add(Bill bill) {
|
||||||
String sql = "INSERT INTO t_bill (bill_Monery) VALUES (?)";
|
String sql = "INSERT INTO t_bill VALUES (0,?,?)";
|
||||||
try (Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
|
try (Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
|
||||||
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
PreparedStatement pstmt = conn.prepareStatement(sql)) {
|
||||||
pstmt.setString(1, someColumn);
|
pstmt.setDate(1, bill.getBillDate());
|
||||||
|
pstmt.setDouble(2, bill.getBillMonery());
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -3,12 +3,12 @@ package com.bwie.pojo;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class bill {
|
public class Bill {
|
||||||
private Integer billId;
|
private Integer billId;
|
||||||
private Date billDate;
|
private Date billDate;
|
||||||
private double billMonery;
|
private double billMonery;
|
||||||
|
|
||||||
public bill() {
|
public Bill() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getBillId() {
|
public Integer getBillId() {
|
||||||
|
@ -19,8 +19,8 @@ public class bill {
|
||||||
this.billId = billId;
|
this.billId = billId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getBillDate() {
|
public java.sql.Date getBillDate() {
|
||||||
return billDate;
|
return (java.sql.Date) billDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBillDate(Date billDate) {
|
public void setBillDate(Date billDate) {
|
||||||
|
@ -35,7 +35,7 @@ public class bill {
|
||||||
this.billMonery = billMonery;
|
this.billMonery = billMonery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bill(Integer billId, Date billDate, double billMonery) {
|
public Bill(Integer billId, Date billDate, double billMonery) {
|
||||||
this.billId = billId;
|
this.billId = billId;
|
||||||
this.billDate = billDate;
|
this.billDate = billDate;
|
||||||
this.billMonery = billMonery;
|
this.billMonery = billMonery;
|
Loading…
Reference in New Issue