Browse Source

初始化

yxk 3 weeks ago
commit
6535910c1f

+ 40 - 0
.gitignore

@@ -0,0 +1,40 @@
+target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
+
+.mvn
+.idea/
+/mvnw
+/mvnw.cmd

+ 69 - 0
pom.xml

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.zhongbei</groupId>
+    <artifactId>zhongbei-test</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>dz-serve</name>
+    <packaging>war</packaging>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <junit.version>5.8.2</junit.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>4.0.1</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-dbutils</groupId>
+            <artifactId>commons-dbutils</artifactId>
+            <version>1.7</version>
+        </dependency>
+
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>8.0.23</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-dbcp2</artifactId>
+            <version>2.8.0</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <version>3.3.2</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 35 - 0
src/main/java/com/zhongbei/dzserve/controller/Hello2Servlet.java

@@ -0,0 +1,35 @@
+package com.zhongbei.dzserve.controller;
+
+import com.zhongbei.dzserve.entity.DeviceParam;
+import com.zhongbei.dzserve.service.DeviceService;
+
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "helloServlet2", value = "/hello-servlet2")
+public class Hello2Servlet extends HttpServlet {
+
+
+    DeviceService deviceService = new DeviceService();
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        int page = Integer.parseInt(request.getParameter("page"));
+        int size = Integer.parseInt(request.getParameter("size"));
+        String aliasName = request.getParameter("aliasName");
+        DeviceParam deviceParam = new DeviceParam();
+        deviceParam.setPage(page);
+        deviceParam.setSize(size);
+        deviceParam.setAliasName(aliasName);
+        response.setContentType("text/html");
+        // Hello
+        PrintWriter out = response.getWriter();
+        out.println("<html><body>");
+        out.println(deviceService.getDevicePage(deviceParam));
+        out.println("<h1>Hello World!</h1>");
+        out.println("</body></html>");
+    }
+}

+ 27 - 0
src/main/java/com/zhongbei/dzserve/controller/HelloServlet.java

@@ -0,0 +1,27 @@
+package com.zhongbei.dzserve.controller;
+
+import java.io.*;
+import javax.servlet.http.*;
+import javax.servlet.annotation.*;
+
+@WebServlet(name = "helloServlet", value = "/hello-servlet")
+public class HelloServlet extends HttpServlet {
+    private String message;
+
+    public void init() {
+        message = "Hello World!";
+    }
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        response.setContentType("text/html");
+
+        // Hello
+        PrintWriter out = response.getWriter();
+        out.println("<html><body>");
+        out.println("<h1>" + message + "</h1>");
+        out.println("</body></html>");
+    }
+
+    public void destroy() {
+    }
+}

+ 67 - 0
src/main/java/com/zhongbei/dzserve/dao/DeviceMapper.java

@@ -0,0 +1,67 @@
+package com.zhongbei.dzserve.dao;
+
+
+import com.zhongbei.dzserve.entity.Device;
+import com.zhongbei.dzserve.entity.DeviceParam;
+import com.zhongbei.dzserve.entity.PageVo;
+import com.zhongbei.dzserve.util.DataSourceUtils;
+
+import java.util.List;
+
+/**
+ * 设备表 Mapper 接口
+ */
+public class DeviceMapper {
+
+    /**
+     * 添加设备
+     */
+    Integer saveDevice(Device device) {
+        return null;
+    }
+
+    /**
+     * 删除设备
+     */
+    Integer deleteDevice(String devicename) {
+        return null;
+    }
+
+    /**
+     * 修改设备
+     */
+    Integer updateDevice(Device device) {
+        return null;
+    }
+
+    /**
+     * 获取全部的设备
+     */
+    public List<Device> listAllDevice() {
+        String sql = "select devicename,alias_name AS aliasName,longitude,latitude from device";
+        return DataSourceUtils.queryList(Device.class, sql);
+    }
+
+    /**
+     * 分页查询设备
+     */
+    public PageVo listPageDevice(DeviceParam param) {
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append("select * from device where 1 = 1 ");
+        if (param.getAliasName() != null && param.getAliasName().equals("")) {
+            stringBuilder.append("and alias_name like").append(" %").append(param.getAliasName()).append("% ");
+        }
+        if (param.getSurveyId() != null) {
+            stringBuilder.append("and survey_id =").append(param.getSurveyId()).append(" ");
+        }
+        //查询数据总数SQL
+        String countSql = "select count(*) from (" + stringBuilder + ") T";
+        stringBuilder.append(" LIMIT ").append(param.getOffset()).append(",").append(param.getSize());
+        String dataSql = stringBuilder.toString();
+
+        long total = DataSourceUtils.queryCount(countSql);
+        List<Device> rows = DataSourceUtils.queryList(Device.class, dataSql);
+        return new PageVo(param.getPage(), total, rows);
+    }
+
+}

+ 48 - 0
src/main/java/com/zhongbei/dzserve/dao/SysUserMapper.java

@@ -0,0 +1,48 @@
+package com.zhongbei.dzserve.dao;
+
+import com.zhongbei.dzserve.entity.SysUser;
+
+import java.util.List;
+
+/**
+ * 用户 Mapper
+ */
+public class SysUserMapper {
+
+    /**
+     * 添加设备
+     */
+    Integer saveUser(SysUser User) {
+        return null;
+    }
+
+    /**
+     * 删除设备
+     */
+    Integer deleteUser(String Username) {
+        return null;
+    }
+
+    /**
+     * 修改设备
+     */
+    Integer updateUser(SysUser User) {
+        return null;
+    }
+
+
+    /**
+     * 分页查询设备
+     */
+    List<SysUser> listPageUser() {
+        return null;
+    }
+
+    /**
+     * 获取全部的设备
+     */
+    List<SysUser> listAllUser() {
+        return null;
+    }
+
+}

+ 31 - 0
src/main/java/com/zhongbei/dzserve/entity/BaseParams.java

@@ -0,0 +1,31 @@
+package com.zhongbei.dzserve.entity;
+
+/**
+ * @author yxk
+ * @since 2024/8/30 15:45
+ */
+public class BaseParams {
+    private int page;
+    private int size;
+
+    public int getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public int getOffset() {
+        return (page - 1) * size;
+    }
+
+}

+ 197 - 0
src/main/java/com/zhongbei/dzserve/entity/Device.java

@@ -0,0 +1,197 @@
+package com.zhongbei.dzserve.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 设备表
+ */
+public class Device implements Serializable {
+
+    /**
+     * 序号
+     */
+    private Integer id;
+
+    /**
+     * 设备编号
+     */
+    private String devicename;
+
+    /**
+     * 设备名称
+     */
+    private String aliasName;
+
+    /**
+     * 设备类型
+     */
+    private String deviceType;
+
+    /**
+     * 测区ID
+     */
+    private Integer surveyId;
+
+    /**
+     * 卡号
+     */
+    private String simNo;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 地址
+     */
+    private String address;
+
+    /**
+     * 安装时间
+     */
+    private LocalDateTime installTime;
+
+    /**
+     * 供电方式
+     */
+    private String powerType;
+
+    /**
+     * 通信方式
+     */
+    private String netType;
+    /**
+     * 经度
+     */
+    private BigDecimal longitude;
+    /**
+     * 纬度
+     */
+    private BigDecimal latitude;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public String getDevicename() {
+        return devicename;
+    }
+
+    public void setDevicename(String devicename) {
+        this.devicename = devicename;
+    }
+
+    public String getAliasName() {
+        return aliasName;
+    }
+
+    public void setAliasName(String aliasName) {
+        this.aliasName = aliasName;
+    }
+
+    public String getDeviceType() {
+        return deviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        this.deviceType = deviceType;
+    }
+
+    public Integer getSurveyId() {
+        return surveyId;
+    }
+
+    public void setSurveyId(Integer surveyId) {
+        this.surveyId = surveyId;
+    }
+
+    public String getSimNo() {
+        return simNo;
+    }
+
+    public void setSimNo(String simNo) {
+        this.simNo = simNo;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public LocalDateTime getInstallTime() {
+        return installTime;
+    }
+
+    public void setInstallTime(LocalDateTime installTime) {
+        this.installTime = installTime;
+    }
+
+    public String getPowerType() {
+        return powerType;
+    }
+
+    public void setPowerType(String powerType) {
+        this.powerType = powerType;
+    }
+
+    public String getNetType() {
+        return netType;
+    }
+
+    public void setNetType(String netType) {
+        this.netType = netType;
+    }
+
+    public BigDecimal getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(BigDecimal longitude) {
+        this.longitude = longitude;
+    }
+
+    public BigDecimal getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(BigDecimal latitude) {
+        this.latitude = latitude;
+    }
+
+    @Override
+    public String toString() {
+        return "Device{" +
+                "id=" + id +
+                ", devicename='" + devicename + '\'' +
+                ", aliasName='" + aliasName + '\'' +
+                ", deviceType='" + deviceType + '\'' +
+                ", surveyId=" + surveyId +
+                ", simNo='" + simNo + '\'' +
+                ", remark='" + remark + '\'' +
+                ", address='" + address + '\'' +
+                ", installTime=" + installTime +
+                ", powerType='" + powerType + '\'' +
+                ", netType='" + netType + '\'' +
+                ", longitude=" + longitude +
+                ", latitude=" + latitude +
+                '}';
+    }
+}

+ 26 - 0
src/main/java/com/zhongbei/dzserve/entity/DeviceParam.java

@@ -0,0 +1,26 @@
+package com.zhongbei.dzserve.entity;
+
+/**
+ * @author yxk
+ * @since 2024/8/30 15:53
+ */
+public class DeviceParam extends BaseParams {
+    private String aliasName;
+    private Integer surveyId;
+
+    public String getAliasName() {
+        return aliasName;
+    }
+
+    public void setAliasName(String aliasName) {
+        this.aliasName = aliasName;
+    }
+
+    public Integer getSurveyId() {
+        return surveyId;
+    }
+
+    public void setSurveyId(Integer surveyId) {
+        this.surveyId = surveyId;
+    }
+}

+ 143 - 0
src/main/java/com/zhongbei/dzserve/entity/GnssSolve.java

@@ -0,0 +1,143 @@
+package com.zhongbei.dzserve.entity;
+
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * GNSS结算数据
+ */
+public class GnssSolve implements Serializable {
+
+    private Integer num;
+
+    private String devicename;
+
+    private String aliasName;
+
+    private String ttime;
+
+    /**
+     * 南北向值
+     */
+    private BigDecimal n;
+
+    /**
+     * 东西向值
+     */
+    private BigDecimal e;
+
+    /**
+     * 高向值
+     */
+    private BigDecimal u;
+
+    /**
+     * 南北向差值
+     */
+    private BigDecimal nd;
+
+    /**
+     * 东西向差值
+     */
+    private BigDecimal ed;
+
+    /**
+     * 高向差值
+     */
+    private BigDecimal ud;
+
+    /**
+     * 水平位移(mm)
+     */
+    private BigDecimal hor;
+
+    /**
+     * 南北向位移速度(mm/d)
+     */
+    private BigDecimal ndSpeed;
+
+    /**
+     * 东西向位移速度(mm/d)
+     */
+    private BigDecimal edSpeed;
+
+    /**
+     * 高向位移速度(mm/d)
+     */
+    private BigDecimal udSpeed;
+
+    /**
+     * 水平向位移速度(mm/d)
+     */
+    private BigDecimal horSpeed;
+
+    /**
+     * 南北向位移加速度(mm/d2)
+     */
+    private BigDecimal ndAcceleration;
+
+    /**
+     * 东西向位移加速度(mm/d2)
+     */
+    private BigDecimal edAcceleration;
+
+    /**
+     * 高向位移加速度(mm/d2)
+     */
+    private BigDecimal udAcceleration;
+
+    /**
+     * 水平向位加移速度(mm/d2)
+     */
+    private BigDecimal horAcceleration;
+
+    public BigDecimal getNd() {
+        return nd.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getEd() {
+        return ed.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getUd() {
+        return ud.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getHor() {
+        return hor.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getNdSpeed() {
+        return ndSpeed.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getEdSpeed() {
+        return edSpeed.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getUdSpeed() {
+        return udSpeed.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getHorSpeed() {
+        return horSpeed.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getNdAcceleration() {
+        return ndAcceleration.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getEdAcceleration() {
+        return edAcceleration.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getUdAcceleration() {
+        return udAcceleration.setScale(2, RoundingMode.HALF_UP);
+    }
+
+    public BigDecimal getHorAcceleration() {
+        return horAcceleration.setScale(2, RoundingMode.HALF_UP);
+    }
+}

+ 52 - 0
src/main/java/com/zhongbei/dzserve/entity/PageVo.java

@@ -0,0 +1,52 @@
+package com.zhongbei.dzserve.entity;
+
+import java.util.List;
+
+/**
+ * @author yxk
+ * @since 2024/8/30 15:48
+ */
+public class PageVo {
+    private long page;
+    private long total;
+    private List<?> rows;
+
+    public PageVo(long page, long total, List<?> rows) {
+        this.page = page;
+        this.total = total;
+        this.rows = rows;
+    }
+
+    public List<?> getRows() {
+        return rows;
+    }
+
+    public void setRows(List<Object> rows) {
+        this.rows = rows;
+    }
+
+    public long getTotal() {
+        return total;
+    }
+
+    public void setTotal(int total) {
+        this.total = total;
+    }
+
+    public long getPage() {
+        return page;
+    }
+
+    public void setPage(int page) {
+        this.page = page;
+    }
+
+    @Override
+    public String toString() {
+        return "PageVo{" +
+                "page=" + page +
+                ", total=" + total +
+                ", rows=" + rows +
+                '}';
+    }
+}

+ 130 - 0
src/main/java/com/zhongbei/dzserve/entity/SysUser.java

@@ -0,0 +1,130 @@
+package com.zhongbei.dzserve.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 用户对象 sys_user
+ *
+ * @author ruoyi
+ */
+public class SysUser implements Serializable {
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 用户账号
+     */
+    private String userName;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 用户昵称
+     */
+    private String nickName;
+
+    /**
+     * 用户性别
+     */
+    private String sex;
+
+    /**
+     * 手机号码
+     */
+    private String phonenumber;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getSex() {
+        return sex;
+    }
+
+    public void setSex(String sex) {
+        this.sex = sex;
+    }
+
+    public String getPhonenumber() {
+        return phonenumber;
+    }
+
+    public void setPhonenumber(String phonenumber) {
+        this.phonenumber = phonenumber;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    @Override
+    public String toString() {
+        return "SysUser{" +
+                "userId=" + userId +
+                ", userName='" + userName + '\'' +
+                ", password='" + password + '\'' +
+                ", nickName='" + nickName + '\'' +
+                ", sex='" + sex + '\'' +
+                ", phonenumber='" + phonenumber + '\'' +
+                ", createTime=" + createTime +
+                ", remark='" + remark + '\'' +
+                '}';
+    }
+}

+ 33 - 0
src/main/java/com/zhongbei/dzserve/service/DeviceService.java

@@ -0,0 +1,33 @@
+package com.zhongbei.dzserve.service;
+
+import com.zhongbei.dzserve.dao.DeviceMapper;
+import com.zhongbei.dzserve.entity.Device;
+import com.zhongbei.dzserve.entity.DeviceParam;
+import com.zhongbei.dzserve.entity.PageVo;
+
+import java.util.List;
+
+/**
+ * 设备 服务类
+ *
+ * @author yxk
+ * @since 2024/8/30 15:24
+ */
+public class DeviceService {
+    DeviceMapper deviceMapper = new DeviceMapper();
+
+    /**
+     * 查询地图数据
+     */
+    public List<Device> getMapData() {
+        return deviceMapper.listAllDevice();
+    }
+
+    /**
+     * 分页查询设备信息
+     */
+    public PageVo getDevicePage(DeviceParam param) {
+        return deviceMapper.listPageDevice(param);
+    }
+
+}

+ 123 - 0
src/main/java/com/zhongbei/dzserve/util/DataSourceUtils.java

@@ -0,0 +1,123 @@
+package com.zhongbei.dzserve.util;
+
+import org.apache.commons.dbutils.QueryRunner;
+import org.apache.commons.dbutils.handlers.BeanHandler;
+import org.apache.commons.dbutils.handlers.BeanListHandler;
+import org.apache.commons.dbutils.handlers.ScalarHandler;
+import org.apache.commons.dbcp2.BasicDataSource;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+/**
+ * 编写数据库连接的工具类,JDBC工具类
+ * 获取连接对象采用读取配置文件方式
+ * 读取文件获取连接,执行一次,static{}
+ */
+public class DataSourceUtils {
+    private static final BasicDataSource dataSource = new BasicDataSource();
+    private static final String driverName = "com.mysql.jdbc.Driver";
+    private static final String url = "jdbc:mysql://lq.ailishi.org:33062/zhongbei_test";
+    private static final String username = "zhongbei";
+    private static final String password = "zhongbei@2024";
+
+
+    static {
+        dataSource.setDriverClassName(driverName);
+        dataSource.setUrl(url);
+        dataSource.setUsername(username);
+        dataSource.setPassword(password);
+        dataSource.setMinIdle(20);
+        dataSource.setMaxIdle(20);
+        dataSource.setMaxOpenPreparedStatements(300);
+    }
+
+
+    public static Connection getConnection() {
+        try {
+            return dataSource.getConnection();
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static <T> T queryOne(Class<T> clazz, String sql, Object... params) {
+        //创建QueryRunner类对象
+        QueryRunner queryRunner = new QueryRunner();
+        //写删除的SQL语句
+        try {
+            return queryRunner.query(getConnection(), sql, new BeanHandler<>(clazz), params);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static <T> List<T> queryList(Class<T> clazz, String sql, Object... params) {
+        //创建QueryRunner类对象
+        QueryRunner queryRunner = new QueryRunner();
+        //写删除的SQL语句
+        try {
+            return queryRunner.query(getConnection(), sql, new BeanListHandler<>(clazz), params);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public static long queryCount(String sql, Object... params) {
+        //创建QueryRunner类对象
+        QueryRunner queryRunner = new QueryRunner();
+        //写删除的SQL语句
+        try {
+            Connection connection = getConnection();
+            return queryRunner.query(connection, sql, new ScalarHandler<>(), params);
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+
+//    public static void delete() throws SQLException {
+//        //创建QueryRunner类对象
+//        QueryRunner qr = new QueryRunner();
+//        //写删除的SQL语句
+//        String sql = "DELETE FROM classmate WHERE id<=?";
+//        //调用QueryRunner方法update
+//        int row = qr.update(conn, sql, 10);
+//        System.out.printf("已经有[%d]发生了改变", row);
+//
+//        DbUtils.closeQuietly(conn);
+//
+//    }
+//
+//
+//    public static void update() throws SQLException {
+//        //创建QueryRunner类对象
+//        QueryRunner qr = new QueryRunner();
+//        //写修改数据的SQL语句
+//        String sql = "UPDATE classmate SET age=? WHERE name=?";
+//        //定义Object数组,存储?中的参数,注意传入的位置哟,不要把顺序写反了!
+//        Object[] params = {18, "尹正杰"};
+//        //调用QueryRunner方法update
+//        int row = qr.update(conn, sql, params);
+//        System.out.printf("已经有[%d]发生了改变", row);
+//        DbUtils.closeQuietly(conn);
+//
+//    }
+//
+//    /*
+//     * 定义方法,使用QueryRunner类的方法update向数据表中,添加数据
+//     */
+//    public static void insert() throws SQLException {
+//        //创建QueryRunner类对象
+//        QueryRunner qr = new QueryRunner();
+//        String sql = "INSERT INTO classmate VALUES(?,?,?,?,?,?,?,?,?,?)";
+//        //将三个?占位符的实际参数,写在数组中
+//        Object[] params = {null, "方合意", 24, "python开发工程师", 100, 60, 89, 94, 92, 87};
+//        //调用QueryRunner类的方法update执行SQL语句
+//        int row = qr.update(conn, sql, params);
+//        DbUtils.closeQuietly(conn);
+//    }
+
+
+}

+ 6 - 0
src/main/webapp/WEB-INF/web.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
+         version="4.0">
+</web-app>

+ 13 - 0
src/main/webapp/index.jsp

@@ -0,0 +1,13 @@
+<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
+<!DOCTYPE html>
+<html>
+<head>
+    <title>JSP - Hello World</title>
+</head>
+<body>
+<h1><%= "Hello World!" %>
+</h1>
+<br/>
+<a href="hello-servlet">Hello Servlet</a>
+</body>
+</html>