master
LQS 2024-07-26 09:17:50 +08:00
parent 0e433b077d
commit 47a5fac051
2 changed files with 11 additions and 8 deletions

View File

@ -1,5 +1,7 @@
package com.bwie.dao;
import com.bwie.pojo.Bill;
import java.sql.*;
public class BillDao {
@ -11,11 +13,12 @@ public class BillDao {
}
// 添加数据到表
public void add(String someColumn) {
String sql = "INSERT INTO t_bill (bill_Monery) VALUES (?)";
public void add(Bill bill) {
String sql = "INSERT INTO t_bill VALUES (0,?,?)";
try (Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, someColumn);
pstmt.setDate(1, bill.getBillDate());
pstmt.setDouble(2, bill.getBillMonery());
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();

View File

@ -3,12 +3,12 @@ package com.bwie.pojo;
import java.util.Date;
public class bill {
public class Bill {
private Integer billId;
private Date billDate;
private double billMonery;
public bill() {
public Bill() {
}
public Integer getBillId() {
@ -19,8 +19,8 @@ public class bill {
this.billId = billId;
}
public Date getBillDate() {
return billDate;
public java.sql.Date getBillDate() {
return (java.sql.Date) billDate;
}
public void setBillDate(Date billDate) {
@ -35,7 +35,7 @@ public class bill {
this.billMonery = billMonery;
}
public bill(Integer billId, Date billDate, double billMonery) {
public Bill(Integer billId, Date billDate, double billMonery) {
this.billId = billId;
this.billDate = billDate;
this.billMonery = billMonery;