疫情信息统计

bean层

package com.Bean;

public class Information {

         private String  name;
         private String  number;
         private String  leibie;
         private String  yuanxi;
         private String   telnumber ;
         private String   jiankangma;
         private String   xingcheng;
         private String   qita;
        
          
         public String getName() {
            return name;
         }
        public void setName(String name) {
             this.name = name;
         }
         public String getNumber() {
             return number;
        }
        public void setNumber(String number) {
             this.number = number;
         }
         public String getLeibie() {
             return leibie;     }
        public void setLeibie(String leibie) {
            this.leibie = leibie;
        }
        public String getYuanxi() {
            return yuanxi;     }
        public void setYuanxi(String yuanxi) {
           this.yuanxi = yuanxi;
       } 
        public String getTelnumber() {
           return telnumber;     }
        public void setTelnumber(String telnumber) {
          this.telnumber = telnumber;
      } 
        public String getJiankangma() {
          return jiankangma;     }
        public void setJiankangma(String jiankangma) {
         this.jiankangma = jiankangma;
     }
        public String getXingcheng() {
            return xingcheng;     }
          public void setXingcheng(String xingcheng) {
           this.xingcheng = xingcheng;
       }
          public String getQita() {
                return qita;     }
              public void setQita(String qita) {
               this.qita = qita;
           }
            
    }

 

dao层

package com.Dao;

import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
 import java.sql.SQLException;
  import com.Util.Userutil;
  import com.Bean.Userbean;
 
 
 public class Userdao {
     
     public void add(Userbean claz) throws ClassNotFoundException, SQLException 
    {
         //获得链接对象
         Connection connection = Userutil.getConnection();
        //准备sql语句
         String sql = "insert into course(studentname,studentID,studenttype,departments,phone,color,hodometer,other) values(?,?,?,?,?,?,?,?)";
        PreparedStatement preparedStatement = null;
         try {
         //创建语句传输对象
         preparedStatement = connection.prepareStatement(sql);
       // preparedStatement = connection.prepareStatement(sql);
         preparedStatement.setString(1, claz.getStudentname());
         preparedStatement.setString(2, claz.getStudentID());
         preparedStatement.setString(3, claz.getStudenttype());
         preparedStatement.setString(4, claz.getDepartments());
         preparedStatement.setString(5, claz.getPhone());
         preparedStatement.setString(6, claz.getColor());
         preparedStatement.setString(7, claz.getHodometer());
         preparedStatement.setString(8, claz.getOther());
     
         preparedStatement.executeUpdate();
         } catch (SQLException e) {
            // TODO Auto-generated catch block
           e.printStackTrace();
        }finally {
            //关闭资源
             
            //DBUtil.close(preparedStatement);
            //DBUtil.close(connection);
        }
        
    }

}

util

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;



/**
 * JDBC快速入门
 */
public class utils {
    public static Connection getConnection() throws ClassNotFoundException, SQLException {
    
           Connection connection = null;//连接数据库
           PreparedStatement ps = null;//Statement 对象用于将 SQL 语句发送到数据库中。
           ResultSet rs = null;
        //1. 导入驱动jar包
        //2.注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
         connection = DriverManager.getConnection("jdbc:mysql://localhost:33063/ef3","root", "152486");
       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();
         }
     }
     
 }

页面

<%@ page language= "java" contentType= "text/html; charset=GB18030"
         pageEncoding= "GB18030" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
    <title>石家庄铁道大学在校学生行程统计</title>
</head>
<body>
    <form action="back.jsp" method="post">
        <table align="center" border="1" width="500">
            <tr>
                <td>1.姓名: </td>
                <td>
                    <label>
                        <input type="text" name="name" />
                    </label>
                </td>
            </tr>
            <tr>
                <td>2.学号 </td>
                <td>
                    <label>
                        <input type="text" name="id" maxlength="8"/>
                    </label>
                </td>
            </tr>
            <tr>
                <td>3.学生类别: </td>
                <td>
                    <label>
                        <input type="radio" name="leibie" value="本科生">本科生
                        <input type="radio" name="leibie" value="研究生" checked>研究生
                    </label>
                </td>
            </tr>
            <tr>
                <td>4.院系:</td>
                <td>
                    <label>
                        <select name="xueyuan">
                            <option value="土木学院">土木学院</option>
                            <option value="机械学院">机械学院</option>
                            <option value="交通学院">交通学院</option>
                            <option value="信息学院" selected>信息学院</option>
                            <option value="经管学院">经管学院</option>
                        </select>
                    </label>
                </td>
            </tr>
            <tr>
                <td>5.联系电话: </td>
                <td>
                    <label>
                        <input type="text" name="phone" maxlength="11"/>
                    </label>
                </td>
            </tr>
            <tr>
                <td>6.健康码颜色: </td>
                <td>
                    <label>
                        <input type="radio" name="color" value="绿码">绿码
                        <input type="radio" name="color" value="黄码" checked>黄码
                        <input type="radio" name="color" value="红码">红码
                    </label>
                </td>
            </tr>
            <tr>
                <td>7.行程统计: </td>
                <td>
                    <label>
                        <input type="checkbox" name="xingcheng"  value="10月30日去过人民医院" />
                        <input type="checkbox" name="xingcheng"  value="10月25日以来去过深泽县人民医院" />
                        <input type="checkbox" name="xingcheng"  value="10月16日以来去过深泽县庄泽村" />
                        <input type="checkbox" name="xingcheng"  value="10月29日以来去过黑龙江哈尔滨市或者黑河市" />
                        <input type="checkbox" name="xingcheng"  value="10月18日以来途径贵州遵义市;北京丰台、昌平" />
                        <input type="checkbox" name="xingcheng" value="10月17日以来到过湖南长沙;青海海东市" checked="checked"/>
                    </label>
                </td>
            </tr>
            <tr>
                <td>8.其他涉疫信息需要填报的 </td>
                <td>
                    <label>
                        <input type="text" name="qita" />
                    </label>
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <input type="submit" value="提交" />
                    <input type="reset" value="重置" />
                </td>
            </tr>
        </table>
    </form>
</body>

 

posted @ 2021-11-24 22:08  清梦韶华  阅读(59)  评论(0编辑  收藏  举报