首页 > 其他分享 >疫情到往记录

疫情到往记录

时间:2022-10-16 14:12:30浏览次数:51  
标签:preparedStatement String 疫情 记录 void sql import public

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>石家庄铁道大学在校学生信息行程信息统计</title>
</head>
<body>
<form action="add.jsp" method="get">
    <table align="center" border="1" width="500">

        <tr>
            <td>姓名 : </td>
            <td>
                <input type="text" name="name" />
            </td>
        </tr>

        <tr>
            <td>学号:</td>
            <td>
                <input type="tel" name="studentid" required pattern="[0-9]{8}"/>
            </td>
        </tr>

        <tr>
            <td>学生类型:</td>
            <td>
                <input type="radio" name="studenttype" value="本科生" >本科生
                <input type="radio" name="studenttype" value="研究生" >研究生
            </td>
        </tr>

        <tr>
            <td>院系:</td>
            <td>
                <select name="college">
                    <option value="土木学院">土木学院</option>
                    <option value="机械学院">机械学院</option>
                    <option value="交通学院">交通学院</option>
                    <option value="信息学院">信息学院</option>
                    <option value="经管学院">经管学院</option>
                </select>
            </td>
        </tr>

        <tr>
            <td>联系电话:</td>
            <td>
                <input type="tel" name="phone" required pattern="[0-9]{11}"/>
            </td>
        </tr>

        <tr>
            <td>行程统计:</td>
            <td>
                <input type="checkbox" name="path" value="10月30日去过人民医院">10月30日去过人民医院<br>
                <input type="checkbox" name="path" value="10月25日以来去过深泽县人民医院">10月25日以来去过深泽县人民医院<br>
                <input type="checkbox" name="path" value="10月16日以来去过深泽县庄泽村">10月16日以来去过深泽县庄泽村<br>
                <input type="checkbox" name="path" value="10月29日以来去过黑龙江哈尔滨市或者黑河市">10月29日以来去过黑龙江哈尔滨市或者黑河市<br>
                <input type="checkbox" name="path" value="10月18日以来途径贵州遵义市;北京丰台、昌平">10月18日以来途径贵州遵义市;北京丰台、昌平<br>
                <input type="checkbox" name="path" value="10月17日以来到过湖南长沙;青海海东市">10月17日以来到过湖南长沙;青海海东市<br>
            </td>
        </tr>

        <tr>
            <td>健康码颜色:</td>
            <td>
                <input type="radio" name="color" value="绿码" >绿码
                <input type="radio" name="color" value="黄码" >黄码
                <input type="radio" name="color" value="红码" >红码
            </td>
        </tr>

        <tr>
            <td>其他涉疫信息需要填报的:</td>
            <td>
                <input type="text" name="other" />
            </td>
        </tr>

        <tr align="center">
            <td colspan="2">
                <input type="submit" value="提交">
            </td>
        </tr>
    </table>
</form>
</body>
</html>

以上是screen界面的html代码。

<%@page import="com.Bean.Bean"%>
<%@page import="com.dao.dao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
  //接收客户端传递过来的参数
  String name = request.getParameter("name");
  String studentid = request.getParameter("studentid");
  String studenttype = request.getParameter("studenttype");
  String faculty = request.getParameter("faculty");
  String phone = request.getParameter("phone");
  String color = request.getParameter("color");
  String path = request.getParameter("path");
  String other = request.getParameter("other");
  // try{
  //if()
  {
    // throw new ClassException("信息填报错误");
  }
  //  else if()
  {
    // throw new ClassException("信息填报错误");
  }
  // else
  {
    Bean A = new Bean();
    A.setName(name);
    A.setStudentid(studentid);
    A.setStudenttype(studenttype);
    A.setFaculty(faculty);
    A.setPhone(phone);
    A.setColor(color);
    A.setPath(path);
    A.setOther(other);
    dao Dao = new dao();
    Dao.add(A);

  }
%>
填报成功<br>
</html>
package com.Bean;
public class Bean {
    private String  name;
    private String  studentid;
    private String  studenttype;
    private String  faculty;
    private String  phone;
    private String  color;
    private String  path;
    private String  other;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name= name;
    }

    public String getStudentid() {
        return studentid;
    }
    public void setStudentid(String studentid) {
        this.studentid = studentid;
    }

    public String getStudenttype() {
        return studenttype;
    }
    public void setStudenttype(String studenttype) {
        this.studenttype = studenttype;
    }

    public String getFaculty() {
        return faculty;     }
    public void setFaculty(String faculty) {
        this.faculty = faculty;
    }

    public String getPhone() {
        return phone;     }
    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getColor() {
        return color;     }
    public void setColor(String color) {
        this.color = color;
    }

    public String getPath() {
        return path;     }
    public void setPath(String path) {
        this.path = path;
    }

    public String getOther() {
        return other;     }
    public void setOther(String other) {
        this.other = other;
    }
}
package com.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.Bean.Bean;
import com.Util.userUtil;
public class dao {
    public void add(Bean claz) throws ClassNotFoundException, SQLException
    {
        //获得链接对象
        Connection connection = userUtil.getConnection();
        //准备sql语句
        String sql = "insert into course(name,studentid,studenttype,faculty,phone,color,path,other) values(?,?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = null;
        try {
            //创建语句传输对象
            preparedStatement = connection.prepareStatement(sql);
            // preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, claz.getName());
            preparedStatement.setString(2, claz.getStudentid());
            preparedStatement.setString(3, claz.getStudenttype());
            preparedStatement.setString(4, claz.getFaculty());
            preparedStatement.setString(5, claz.getPhone());
            preparedStatement.setString(6, claz.getColor());
            preparedStatement.setString(7, claz.getPath());
            preparedStatement.setString(8, claz.getOther());
            preparedStatement.executeUpdate();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
            //关闭资源

            //DBUtil.close(preparedStatement);
            //DBUtil.close(connection);
        }

    }
}
package com.Util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class userUtil {
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        Connection connection = null;//连接数据库
        Statement stmt = null;//Statement 对象用于将 SQL 语句发送到数据库中。
        ResultSet rs = null;
        //1. 导入驱动jar包
        //2.注册驱
        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/qz", "root", "mysqlmima");

        return connection;
    }

    public static void close(Connection connection ) {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    public static void close(PreparedStatement preparedStatement ) {
        try {
            if (preparedStatement != null) {
                preparedStatement.close();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    public static void close(ResultSet resultSet ) {
        try {
            if (resultSet != null) {
                resultSet.close();
            }

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

 

标签:preparedStatement,String,疫情,记录,void,sql,import,public
From: https://www.cnblogs.com/yzx-sir/p/16796123.html

相关文章

  • 挖土机杯 CSP-J 组模拟赛 R2 记录
    题外话:我以为10:00开始的......没有足够时间搞,不过题目总体而言难度不大,虽然但是也没赛时AC两题。T1比较简单的送分题,就是分数的加减及约分而已,最后来个特判0和整除。至于......
  • 基于git 提交记录打标签
    列出所有标签:gittag-n获取历史的commit提交记录:gitlog--pretty=oneline--abbrev-commit打标签:gittag-a"指定标签名"-m"tag注释说明"commitID将本地tag推......
  • 正则表达式-逻辑”非“处理(记录)
    正则表达式-逻辑”非“处理(记录)“非”是正则表达式中最难处理的逻辑关系。因为没有直接对应的结构,“非”的处理比较吃力。最简单的“非”,意思是此处不能出现某个字符......
  • 【教程记录】如何卸载永中office
    场景:偶然发现永中office的卸载有点与众不同,无奈上网查了一下,竟然这样就可以了,是我见过的唯一一款需要这样卸载的软件,记录下来以留用。过程:文章中的截图除了最后一张是我自己......
  • 后疫情时代,华为云会议如何在静默中发声
    近年疫情对各行各业的打击无疑是相当沉重的,在面对突如其来的静默、隔离、封控,各种决策根本无法执行到位,相当多的企业在此类情况下的焦急好似鲠在喉般的难受,重要决策的会议不......
  • F5 LTM fullnat模式测试记录及配置
    基础信息拓扑图F5版本Web:Statistics->Dashboardtmsh:root@(test)(cfg-syncStandalone)(Active)(/Common)(tmos)#showsysversionSys::VersionMainPackage......
  • 记录--关于 HTML5 LocalStorage 的 5 个不为人知的事实
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助LocalStorage是HTML5中一个方便使用的API,它为Web开发人员提供了一个易于使用的5MB的存储空间。使用L......
  • 刚看完spaceX记录片《回到太空》
    刚看完这部《回到太空》,跟前几周看的那部《不要抬头看》刚好形成对比,一部是记录片,真实人的情感,一部是名演员,但是所描述的也很宏观。之前看过埃隆马斯克的自传,虽然还没......
  • [ds 记录]P5901 [IOI2009]Regions
    这道题的难点,恐怕在复杂度分析(link首先我们可以自由选择把询问放到上面或下面。放到上面,等价于对每个点求其子树内有多少某颜色的点;放到下面,等价于对每个点求其祖先中有......
  • c++游戏客户端修改记录
    c++游戏客户端编译原代码是基于WTL8.0的,可能是vs2005版本编译。本次使用vs2013升级,之后主要遇到的错误记录在此,最后编译成功了项目中已经引入了wtl8的头文件到include......