1120day-户别确认
1、实体类
package com.edu.empity;
public class People {
private String hubie;
private String livetype;
private String area;
private String roomnum;
private String name;
private String idcard;
private String sex;
private String nation;
private String education;
public String getHubie() {
return hubie;
}
public void setHubie(String hubie) {
this.hubie = hubie;
}
public String getLivetype() {
return livetype;
}
public void setLivetype(String livetype) {
this.livetype = livetype;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getRoomnum() {
return roomnum;
}
public void setRoomnum(String roomnum) {
this.roomnum = roomnum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIdcard() {
return idcard;
}
public void setIdcard(String idcard) {
this.idcard = idcard;
}
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 getEducation() {
return education;
}
public void setEducation(String education) {
this.education = education;
}
public People(String hubie, String livetype, String area, String roomnum, String name, String idcard, String sex,
String nation, String education) {
super();
this.hubie = hubie;
this.livetype = livetype;
this.area = area;
this.roomnum = roomnum;
this.name = name;
this.idcard = idcard;
this.sex = sex;
this.nation = nation;
this.education = education;
}
public People() {
// TODO 自动生成的构造函数存根
}
}
2、dao层
package com.edu.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.edu.dbu.DBUtil;
import com.edu.empity.People;
public class Peopledao {
public List<People> getallPeople() {
List<People> list = new ArrayList<People>();
Connection conn = null;
conn = DBUtil.getConnection();
PreparedStatement pst =null;
ResultSet rs = null;
String sql = "select * from people";
try {
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
while(rs.next()) {
People people = new People();
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
people.setHubie(rs.getString("hubie"));
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
return list;
}
public boolean Addpeople(People people) throws SQLException {
// TODO 自动生成的方法存根
String sql = "insert into people(hubie,livetype,area,roomnum,name,idcard,sex,nation,education)values(?,?,?,?,?,?,?,?,?)";
Connection conn = DBUtil.getConnection();
PreparedStatement pst =null;
int p =0;
try {
pst = conn.prepareStatement(sql);
pst.setString(1, people.getHubie());
pst.setString(2, people.getLivetype());
pst.setString(3, people.getArea());
pst.setString(4, people.getRoomnum());
pst.setString(5, people.getName());
pst.setString(6, people.getIdcard());
pst.setString(7, people.getSex());
pst.setString(8, people.getNation());
pst.setString(9, people.getEducation());
p = pst.executeUpdate();
pst.close();
conn.close();
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}finally {
if(p != 0) {
System.out.println("dao信息添加成功");
}
}
return true;
}
public boolean Updatepeople(People people) throws SQLException {
// TODO 自动生成的方法存根
Connection conn = DBUtil.getConnection();
String sql = "update people set hubie=? livetype=? area=? roomnum=? idcard=? sex=? nation=? education=? where name = ?";
PreparedStatement pst =null;
int p =0;
try {
pst = conn.prepareStatement(sql);
pst.setString(1, people.getHubie());
pst.setString(2, people.getLivetype());
pst.setString(3, people.getArea());
pst.setString(4, people.getRoomnum());
pst.setString(5, people.getIdcard());
pst.setString(6, people.getSex());
pst.setString(7, people.getNation());
pst.setString(8, people.getEducation());
pst.setString(9, people.getName());
p = pst.executeUpdate();
pst.close();
conn.close();
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}finally {
if(p != 0) {
System.out.println("dao信息修改成功");
}
}
return true;
}
public boolean Deletepeople(String name) throws SQLException {
// TODO 自动生成的方法存根
Connection conn = DBUtil.getConnection();
String sql = "delete from people where name = ?";
PreparedStatement pst =null;
int p =0;
try {
pst = conn.prepareStatement(sql);
pst.setString(1, name);
p = pst.executeUpdate();
pst.close();
conn.close();
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}finally {
if(p != 0) {
System.out.println("dao信息删除成功");
}
}
return true;
}
}
3、servlet
1)Add
package com.edu.servlet;
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;
import com.edu.dao.Peopledao;
import com.edu.empity.People;
@WebServlet("/Addservlet")
public class Addservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String hubie = request.getParameter("hubie");
String livetype = request.getParameter("livetype");
String area = request.getParameter("area");
String roomnum = request.getParameter("roomnum");
String name = request.getParameter("name");
String idcard = request.getParameter("idcard");
String sex = request.getParameter("sex");
String nation = request.getParameter("nation");
String education = request.getParameter("education");
System.out.println(hubie+livetype+area+roomnum+name+idcard+sex+nation+education);
Peopledao dao = new Peopledao();
People people = new People(hubie,livetype,area,roomnum,name,idcard,sex,nation,education);
boolean flag = false;
try {
flag=dao.Addpeople(people);
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}finally {
if(flag) {
System.out.println("servlet信息添加成功");
}
}
request.getRequestDispatcher("showpeople.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
2)delete
package com.edu.servlet;
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;
import com.edu.dao.Peopledao;
@WebServlet("/Deleteservlet")
public class Deleteservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
Peopledao dao = new Peopledao();
try {
if(name!=null) {
dao.Deletepeople(name);
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
request.getRequestDispatcher("showpeople.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
3)update
package com.edu.servlet;
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;
import com.edu.dao.Peopledao;
import com.edu.empity.People;
@WebServlet("/Updateservlet")
public class Updateservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("utf-8");
String hubie = request.getParameter("hubie");
String livetype = request.getParameter("livetype");
String area = request.getParameter("area");
String roomnum = request.getParameter("roomnum");
String name = request.getParameter("name");
String idcard = request.getParameter("idcard");
String sex = request.getParameter("sex");
String nation = request.getParameter("nation");
String education = request.getParameter("education");
People people = new People(hubie,livetype,area,roomnum,name,idcard,sex,nation,education);
Peopledao dao = new Peopledao();
try {
if(name != null) {
dao.Updatepeople(people);
}
} catch (SQLException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
request.getRequestDispatcher("showpeople.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
1120day-户别确认的更多相关文章
- Access一些常用的SQL语句
您可以将 Microsoft Office Access 2013 用作创建.修改数据库以及处理数据的工具,还可将 Office Access 2013 用作服务器数据库管理系统(如 Microsof ...
- DOS程序员手册(九)
第14章参考手册概述 本书余下的章节将向读者们介绍BIOS.DOS各种各样API函数和服务,作为一名程 序员,了解和掌握这些知识是很有好处的.在所介绍的参考手册中,每部手册都汇集了大 量的资源 ...
- 二级Parser应用教程
01 应用背景 Ubidots是一个物联网云平台,通过设备友好的API(可通过HTTP / MQTT / TCP / UDP协议访问)简单安全地将硬件和数字输入连接到Ubidots Cloud. 它可 ...
- TCP三次握手Linux源码解析
TCP是面向连接的协议.面向连接的传输层协议在原点和重点之间建立了一条虚拟路径,同属于一个报文的所有报文段都沿着这条虚拟路径发送,为整个报文使用一条虚拟路径能够更容易地实施确认过程以及对损伤或者丢失报 ...
- 08_Linux基础-vim-tmux-字符编码
@ 目录 08_Linux基础-vim-tmux-字符编码 一. vim vim编辑器作用 vim模式 vim命令模式 vim编辑模式 vim末行模式 vim视图模式 vim替换模式 练习 vim常用 ...
- 解析大型.NET ERP系统 电子邮件系统帐户集成
为保证ERP系统的信息流准确快速的传递,需要给系统设计一个消息盒子机制.当系统中发生业务操作后,需要提醒下一个环节的操作人员,以保证ERP信息流快速准确传递.比如生产任务单(工作单,加工单,制单)过帐 ...
- ZSDR017-客户订货价格和库存
*----------------------------------------------------------------------*ZSDR017-客户订货价格和库存*---------- ...
- Win7家庭版开启Administrator管理员帐户的方法
Win7家庭版开启Administrator管理员帐户的方法 发布时间:2014-11-17 18:30:06来源:系统盒浏览数:2786 很多用户安装好Win7系统第一步就是开启Administra ...
- win7 IIS7.0 【IIS 管理器无法验证此内置帐户是否有访问权】
异常信息: 服务器配置为将传递身份验证和内置帐户一起使用,以访问指定的物理路径.但是,IIS 管理器无法验证此内置帐户是否有访问权.请确保应用程序池标识具有该物理路径的读取访问权.如果此服务器加入到域 ...
- 为什么我的outlook只能收信不能发信,发送测试电子邮件消息: 无法发送此邮件。请在帐户属性中验证电子邮件
链接地址:http://zhidao.baidu.com/link?url=aVIFo2aNLuHIZGZuEUataHkZp4XApHqyvbEK8ACHPhi3jwhGhM0GBAtm72AnsP ...
随机推荐
- JAVA中Map集合遍历
for (Map.Entry<String, String> entry : map.entrySet()) { System.out.println("key= " ...
- layUI中layDate控件兼容性问题(手机端没有效果,不显示)
使用layDate插件发现在PC端无问题,然而在适配移动端时,发现点击input时,laydate渲染出的时间控件有时候没有反应,后发现只需在render里加入trigger: 'click',即可以 ...
- 自己常用的CMake用法总结
欢迎指正 CMake : A.download : https://cmake.org/download/ B.tutorial: https://cmake.org/cmake-tutorial/ ...
- 【LeetCode】367. Valid Perfect Square 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:完全平方式性质 方法二:暴力求解 方法三:二 ...
- 【LeetCode】414. Third Maximum Number 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 替换最大值数组 使用set 三个变量 日期 题目地址 ...
- 【LeetCode】888. Fair Candy Swap 公平的糖果棒交换(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人公众号: 每日算法题 本文关键词:力扣,LeetCode,算法题,算法,Python 目录 题目描述 题目大意 解题方法 代码 刷题心得 关于作 ...
- 第五十一个知识点:什么是基于ID的加密的安全模型,然后描述一个IBE方案
第五十一个知识点:什么是基于ID的加密的安全模型,然后描述一个IBE方案 在公钥密码学中,如果Alice想要给Bob发送一条消息,她需要Bob的公钥,一般来说公钥都很长,就像一个随机的字符串. 假设A ...
- Google Chrome调整控制台的位置
众所周知,控制台是开发必备的工具,学会流畅的使用控制台会给我们的开发带来不一样的体验,但是控制台的位置有时却是困扰我们的一件事,控制台默认是在浏览器内,有时十分妨碍我们,那么有没有什么办法修改控制台的 ...
- [Guide]Google Python Style Guide
扉页 项目主页 Google Style Guide Google 开源项目风格指南 - 中文版 背景 Python 是Google主要的脚本语言.这本风格指南主要包含的是针对python的编程准则. ...
- bat文件调用cmd命令批量提取文件夹中的文件名(批量修改文件扩展名)
前言: 在平时的工作中,经常需要批量统计文件和数据,如果逐个统计的话太耗时,而且容易出错那么有没有什么快速的方法呢,这里给大家介绍一种简单高效的方法. 方法: 1.打开CMD命令: 按下 Ctrl+R ...