commit 4530504eeaf384c099065885e7eced05e3d07b43 Author: 少年梦与砖 <2847127106@qq.com> Date: Fri Jul 26 09:31:36 2024 +0800 日考8 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09bdfea --- /dev/null +++ b/.gitignore @@ -0,0 +1,46 @@ +###################################################################### +# Build Tools + +.gradle +/build/ +!gradle/wrapper/gradle-wrapper.jar + +target/ +!.mvn/wrapper/maven-wrapper.jar + +###################################################################### +# IDE + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### JRebel ### +rebel.xml +### NetBeans ### +nbproject/private/ +build/* +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +###################################################################### +# Others +*.log +*.xml.versionsBackup +*.swp + +!*/build/*.java +!*/build/*.html +!*/build/*.xml \ No newline at end of file diff --git a/billManager.iml b/billManager.iml new file mode 100644 index 0000000..8dd6e1c --- /dev/null +++ b/billManager.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/mysql-connector-java-8.0.11.jar b/lib/mysql-connector-java-8.0.11.jar new file mode 100644 index 0000000..c8b8b3f Binary files /dev/null and b/lib/mysql-connector-java-8.0.11.jar differ diff --git a/out/production/billManager/com/bw/dao/Bill.class b/out/production/billManager/com/bw/dao/Bill.class new file mode 100644 index 0000000..41694d6 Binary files /dev/null and b/out/production/billManager/com/bw/dao/Bill.class differ diff --git a/out/production/billManager/com/bw/servlet/BillServlet.class b/out/production/billManager/com/bw/servlet/BillServlet.class new file mode 100644 index 0000000..44da7fe Binary files /dev/null and b/out/production/billManager/com/bw/servlet/BillServlet.class differ diff --git a/out/production/billManager/com/bw/util/BaseDao.class b/out/production/billManager/com/bw/util/BaseDao.class new file mode 100644 index 0000000..4f22c33 Binary files /dev/null and b/out/production/billManager/com/bw/util/BaseDao.class differ diff --git a/sql/day08.sql b/sql/day08.sql new file mode 100644 index 0000000..a5933a3 --- /dev/null +++ b/sql/day08.sql @@ -0,0 +1,37 @@ +/* + Navicat Premium Data Transfer + + Source Server : 本机 + Source Server Type : MySQL + Source Server Version : 50744 + Source Host : localhost:3306 + Source Schema : high-six-exam + + Target Server Type : MySQL + Target Server Version : 50744 + File Encoding : 65001 + + Date: 26/07/2024 09:16:23 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for day08_bill +-- ---------------------------- +DROP TABLE IF EXISTS `day08_bill`; +CREATE TABLE `day08_bill` ( + `billId` int(11) NOT NULL AUTO_INCREMENT COMMENT '账单编号', + `billDate` datetime NULL DEFAULT NULL COMMENT '账单时间', + `billMonerv` double(10, 2) NULL DEFAULT NULL COMMENT '账单金额', + PRIMARY KEY (`billId`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of day08_bill +-- ---------------------------- +INSERT INTO `day08_bill` VALUES (1, '2024-07-26 09:03:23', 111.00); +INSERT INTO `day08_bill` VALUES (2, '2024-07-27 09:03:29', 222.00); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/com/bw/dao/Bill.java b/src/com/bw/dao/Bill.java new file mode 100644 index 0000000..414d0d3 --- /dev/null +++ b/src/com/bw/dao/Bill.java @@ -0,0 +1,55 @@ +package com.bw.dao; + + +/** + * @Author:胡杨 + * @name:Bill + * @Date:2024/7/26 上午8:42 + * @Description: com.bw.dao + */ + +public class Bill { + + /** 账单编号*/ + private String billId; + + /** 账单时间*/ + private String billDate; + + /** 账单金额*/ + private String billMonerv; + + + public String getBillId() { + return billId; + } + + public void setBillId(String billId) { + this.billId = billId; + } + + public String getBillDate() { + return billDate; + } + + public void setBillDate(String billDate) { + this.billDate = billDate; + } + + public String getBillMonerv() { + return billMonerv; + } + + public void setBillMonerv(String billMonerv) { + this.billMonerv = billMonerv; + } + + public Bill() { + } + + public Bill(String billId, String billDate, String billMonerv) { + this.billId = billId; + this.billDate = billDate; + this.billMonerv = billMonerv; + } +} diff --git a/src/com/bw/servlet/BillServlet.java b/src/com/bw/servlet/BillServlet.java new file mode 100644 index 0000000..7f767dd --- /dev/null +++ b/src/com/bw/servlet/BillServlet.java @@ -0,0 +1,33 @@ +package com.bw.servlet; + +import com.bw.util.BaseDao; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.Date; + +/** + * @Author:胡杨 + * @name:BillServlet + * @Date:2024/7/26 上午8:52 + * @Description: com.bw.servlet + */ + + +public class BillServlet { + + public static void main(String[] args) { + try { + Connection connection = BaseDao.create(); + CallableStatement callableStatement = connection.prepareCall("select * from day08_bill"); + + int billId = callableStatement.getInt("billId"); + Date billDate = callableStatement.getDate("billDate"); + double billMonerv = callableStatement.getDouble("billMonerv"); + System.out.println(billId+" "+billDate+" "+billMonerv); + connection.close(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/com/bw/util/BaseDao.java b/src/com/bw/util/BaseDao.java new file mode 100644 index 0000000..208a0e3 --- /dev/null +++ b/src/com/bw/util/BaseDao.java @@ -0,0 +1,28 @@ +package com.bw.util; + +import java.sql.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @Author:胡杨 + * @name:BaseDao + * @Date:2023/11/22 14:33 + * @Description: com.bw.util + */ +public class BaseDao { + public static Connection create() throws Exception { + Class.forName("com.mysql.cj.jdbc.Driver"); + Connection conn = DriverManager.getConnection("jdbc:mysql:///high-six-exam","root","root550011ROOT"); + return conn; + } + public static void close(ResultSet rs, PreparedStatement ps,Connection conn) throws SQLException { + rs.close(); + ps.close(); + conn.close(); + } + public static void close(PreparedStatement ps,Connection conn) throws SQLException { + ps.close(); + conn.close(); + } +} diff --git a/理论/1721957083813.png b/理论/1721957083813.png new file mode 100644 index 0000000..1d15eba Binary files /dev/null and b/理论/1721957083813.png differ diff --git a/理论/1721957103356.png b/理论/1721957103356.png new file mode 100644 index 0000000..7be4394 Binary files /dev/null and b/理论/1721957103356.png differ diff --git a/理论/1721957119264.png b/理论/1721957119264.png new file mode 100644 index 0000000..a020cc4 Binary files /dev/null and b/理论/1721957119264.png differ diff --git a/理论/1721957133645.png b/理论/1721957133645.png new file mode 100644 index 0000000..2fb9d63 Binary files /dev/null and b/理论/1721957133645.png differ