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;
}
}
1010day-人口普查系统的更多相关文章
- 人口信息普查系统-JavaWeb-五
今天分享人口普查系统删除查询前端代码 <%@ page language="java" contentType="text/html; UTF-8" pa ...
- 人口信息普查系统-JavaWeb-四
今天给大家分享前端人口登记页面,人口查询页面 人口登记 <%@ page language="java" contentType="text/html; chars ...
- 人口信息普查系统-JavaWeb-三
今天给大家分享前端主页面的代码,设有五个功能.涉及到增删改查,用到了超链接的跳转. <!DOCTYPE html> <html lang="en"> < ...
- 人口信息普查系统-JavaWeb-二
上次发表了人口普查系统的题目要求,今天和大家分享一下我的技术方案. 技术上用到的是html+jsp+JavaBean+servlet+JavaScript 其实现在的前端页面主流还是html,它可以实 ...
- 人口信息普查系统-JavaWeb-一
建民说要期中考试了,我赶紧翻阅了去年的考试题目,去年的试题是要求做一个人口普查系统.我就试着做了一下,今天主要和大家分享题目要求. 其中考试确实有些难度,用到了许多没有接触过的知识,比如JavaScr ...
- PAT 1028. 人口普查(20)
某城镇进行人口普查,得到了全体居民的生日.现请你写个程序,找出镇上最年长和最年轻的人. 这里确保每个输入的日期都是合法的,但不一定是合理的--假设已知镇上没有超过200岁的老人,而今天是2014年9月 ...
- PAT (Basic Level) Practise:1028. 人口普查
[题目链接] 某城镇进行人口普查,得到了全体居民的生日.现请你写个程序,找出镇上最年长和最年轻的人. 这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过200岁的老人,而今天是 ...
- PAT乙级 1028. 人口普查(20)
1028. 人口普查(20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 某城镇进行人口普查,得到了全体居民的 ...
- PAT1028—— 人口普查
某城镇进行人口普查,得到了全体居民的生日.现请你写个程序,找出镇上最年长和最年轻的人. 这里确保每个输入的日期都是合法的,但不一定是合理的——假设已知镇上没有超过200岁的老人,而今天是2014年9月 ...
- PAT-乙级-1028. 人口普查(20)
1028. 人口普查(20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 某城镇进行人口普查,得到了全体居民的 ...
随机推荐
- vscode 设置
{ "security.workspace.trust.enabled": false, "workbench.editor.enablePreview": f ...
- JAVA中BufferedImage与byte[]转换
BufferedImage转byte[] ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(imgBuff, ...
- Spring Boot应用程序启动器
官网地址:https://docs.spring.io/spring-boot/docs/2.1.12.RELEASE/reference/html/using-boot-build-systems. ...
- JS监控浏览器窗口是否活动,最小化操作
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JAVA加解密之DES
DES加密算法是一种分组密码,以64位为分组对数据加密,它的密钥长度是56位,加密解密用同一算法.DES加密算法是对密钥进行保密,而公开算法,包括加密和解密算法.这样,只有掌握了和发送方相同密钥的人才 ...
- 【LeetCode】880. Decoded String at Index 解题报告(Python)
[LeetCode]880. Decoded String at Index 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...
- Docker 与 K8S学习笔记(二)—— 容器核心知识梳理
本篇主要对容器相关核心知识进行梳理,通过本篇的学习,我们可以对容器相关的概念有一个全面的了解,这样有利于后面的学习. 一.什么是容器? 容器是一种轻量级.可移植.自包含的软件打包技术,使应用程序可以在 ...
- 『学了就忘』vim编辑器基础 — 97、vim使用技巧
目录 1.在vim中导入其他文件内容或命令结果 (1)导入其他文件内容 (2)在vim中执行系统命令 (3)导入命令结果 2.设定快捷键 3.字符替换 4.多文件打开 vim使用技巧,就是vim编辑器 ...
- MMD
目录 概 主要内容 定义 MMD for kernel function classes 一个无偏统计量 MMD test Borgwardt K., Gretton A., Rasch M., Kr ...
- Python Revisited Day10 (进程与线程)
目录 10.1 使用多进程模块 10.2 将工作分布到多个线程 <Python 3 程序开发指南>学习笔记 有俩种方法可以对工作载荷进行分布,一种是使用多进程,另一种是使用多线程. 10. ...