• 1010day人口普查系统


    1、xiugai.java

    package com.edu.ia;

    import java.io.IOException;
    import java.sql.SQLException;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class xiugai
    */
    @WebServlet("/xiugai")
    public class xiugai extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String name=request.getSession().getAttribute("name").toString();
    String ID=request.getParameter("ID");
    String sex=request.getParameter("sex");
    String nation=request.getParameter("nation");
    String educator=request.getParameter("educator");
    hand L=new hand();
    try {
    L.update(name, ID, sex, nation, educator);
    request.getRequestDispatcher("jieguo.jsp").forward(request, response);
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    2、shanchu.java

    package com.edu.ia;

    import java.io.IOException;
    import java.sql.SQLException;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class shanchu
    */
    @WebServlet("/shanchu")
    public class shanchu extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String name=request.getParameter("name");
    hand L=new hand();
    try {
    L.delete(name);
    request.getRequestDispatcher("getResult.jsp").forward(request, response);
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    3、People.java

    package com.edu.ia;

    import java.io.IOException;
    import java.sql.SQLException;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    /**
    * Servlet implementation class People
    */
    @WebServlet("/People")
    public class People extends HttpServlet {
    private static final long serialVersionUID = 1L;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String hubie=request.getParameter("hubie");
    String zhufang=request.getParameter("zhufang");
    String mianji=request.getParameter("mianji");
    String fangjianshu=request.getParameter("fangjianshu");
    String name=request.getParameter("name");
    String ID=request.getParameter("ID");
    String sex=request.getParameter("sex");
    String nation=request.getParameter("nation");
    String educator=request.getParameter("educator");
    get login=new get(hubie,zhufang,mianji,fangjianshu,name,ID,sex,nation,educator);
    hand L=new hand();
    try {
    L.insert(login);
    request.getRequestDispatcher("Browse.jsp").forward(request, response);
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    4、hand.java

    package com.edu.ia;

    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;

    public class hand {
    public void insert(get L) throws SQLException {
    String sql = "insert into test(hubie,zhufang,mianji,fangjianshu,name,ID,sex,nation,educator)values(?,?,?,?,?,?,?,?,?)";
    Connection connection = DBUtil.getConnection();
    PreparedStatement preparedStatement = null;
    preparedStatement = connection.prepareStatement(sql);
    preparedStatement.setString(1,L.getHubie());
    preparedStatement.setString(2,L.getZhufang());
    preparedStatement.setString(3,L.getMianji());
    preparedStatement.setString(4,L.getFangjianshu());
    preparedStatement.setString(5,L.getName());
    preparedStatement.setString(6,L.getID());
    preparedStatement.setString(7,L.getSex());
    preparedStatement.setString(8,L.getNation());
    preparedStatement.setString(9,L.getEducator());
    preparedStatement.execute();
    }
    public void update(String name,String ID,String sex,String nation,String educator) throws SQLException {
    String sql="UPDATE test SET ID=?,sex=?,nation=?,educator=? where name=?";
    Connection conn= DBUtil.getConnection();
    PreparedStatement papre=conn.prepareStatement(sql);
    papre.setString(1, ID);
    papre.setString(2, sex);
    papre.setString(3, nation);
    papre.setString(4, educator);
    papre.setString(5, name);
    papre.execute();
    }
    public void delete(String name) throws SQLException {
    String sql="delete from test where name=?";
    Connection conn= DBUtil.getConnection();
    PreparedStatement papre=conn.prepareStatement(sql);
    papre.setNString(1, name);
    papre.execute();
    }
    }

    5、get.java

    package com.edu.ia;

    public class get {
    String hubie;
    String zhufang;
    String mianji;
    String fangjianshu;
    String name;
    String ID;
    String sex;
    String nation;
    String educator;
    public String getHubie() {
    return hubie;
    }
    public void setHubie(String hubie) {
    this.hubie = hubie;
    }
    public String getZhufang() {
    return zhufang;
    }
    public void setZhufang(String zhufang) {
    this.zhufang = zhufang;
    }
    public String getMianji() {
    return mianji;
    }
    public void setMianji(String mianji) {
    this.mianji = mianji;
    }
    public String getFangjianshu() {
    return fangjianshu;
    }
    public void setFangjianshu(String fnagjianshu) {
    this.fangjianshu = fnagjianshu;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getID() {
    return ID;
    }
    public void setID(String iD) {
    ID = iD;
    }
    public String getSex() {
    return sex;
    }
    public void setSex(String sex) {
    this.sex = sex;
    }
    public String getNation() {
    return nation;
    }
    public void setNation(String nation) {
    this.nation = nation;
    }
    public String getEducator() {
    return educator;
    }
    public void setEducator(String educator) {
    this.educator = educator;
    }
    public get(String a,String b,String c,String d,String e,String f,String h,String g,String n) {
    hubie=a;
    zhufang=b;
    mianji=c;
    fangjianshu=d;
    name=e;
    ID=f;
    sex=h;
    nation=g;
    educator=n;
    }
    }

  • 相关阅读:
    IdTCP的C++Builder2010示例(转)
    BCB实现BMP图片的RGB分解(转)
    c++ builder 2009如何生成独立运行exe(转)
    用于ARM上的FFT与IFFT源代码(C语言,不依赖特定平台)(转)
    灰度变换——反转,对数变换,伽马变换,灰度拉伸,灰度切割,位图切割
    XS128超声波程序
    兔子--ps中的基本工具总结(ps cs5)
    UML中的用例图
    hdu5400Arithmetic Sequence
    自己定义控件的onMeasure方法具体解释
  • 原文地址:https://www.cnblogs.com/lx06/p/14165066.html
Copyright © 2020-2023  润新知