日考8
commit
4530504eea
|
@ -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
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library name="Unnamed">
|
||||||
|
<CLASSES />
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
<orderEntry type="library" name="lib" level="project" />
|
||||||
|
<orderEntry type="library" name="lib (2)" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -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;
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Loading…
Reference in New Issue