• 人口普查系统--信息删除


    <%@ page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8"%><%@ page import="java.sql.*"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>修改信息</title>
    </head>
    <body>
    <%
    final String URL = "jdbc:mysql://localhost:3306/test";
    final String USERNAME = "root";
    final String PWD = "12345";
    Connection connection = null;
    Statement  stmt = null;
    ResultSet rs = null ; 
    request.setCharacterEncoding("utf-8") ;
    
    String name=request.getParameter("selname");
    
    try {
    	// a.导入驱动,加载具体的驱动类
    	Class.forName("com.mysql.jdbc.Driver");// 加载具体的驱动类
    	// b.与数据库建立连接
    	connection = DriverManager.getConnection(URL, USERNAME, PWD);
    	stmt = connection.createStatement();
    	
    	
    	String sql = "select * from pucha where name='"+name+"'  " ;
    
    	// 执行SQL
    	rs = stmt.executeQuery(sql);
    	
    	// d.处理结果
    	while(rs.next()) {  
    		String hb=request.getParameter("hubie");
    		String type=rs.getString("htype");
    		String mj=rs.getString("mianji");
    		String fjs=rs.getString("fangjianshu");
    		String hname=rs.getString("name");
    		String id=rs.getString("id");
    		String xb=rs.getString("xingbie");
    		String mz=rs.getString("minzu");
    		String degree=rs.getString("degree");
    		out.print(type+"--"+mj+"--"+fjs+"--"+hname+"--"+id+"--"+xb+"--"+mz+"--"+degree+"--"+hb);
    		
    	}
    } catch (ClassNotFoundException e) {
    	e.printStackTrace();
    } catch (SQLException e) {
    	e.printStackTrace();
    } catch(Exception e) {
    	e.printStackTrace();
    }
    finally {
    	try {
    		 if(stmt!=null) stmt.close();// 对象.方法
    		 if(connection!=null)connection.close();
    	}catch(SQLException e) {
    		e.printStackTrace();
    	}
    }
    
    
    
    %>
    <form action="Cwancheng.jsp">
    <table align="center">
    	<tr><td>请输入要删除的户主姓名<input type="text"name="selname"></td></tr>
    	
    	<tr>
    		<td><input type="reset"value="重置"></td>
    		<td><input type="submit"value="提交"></td>
    	</tr>
    
    </table>
    </form>
    
    
    </body>
    </html>
    

      

  • 相关阅读:
    三种方式重启NGINX 简单
    转MongoDB、HandlerSocket和MySQL性能测试及其结果分析 简单
    php ini_set post_max_size,upload_max_filesize 简单
    grep 命令 简单
    ANSI,GBK,UTF8,UTF16LE,UTF16BE 简单
    提升工作效率软件 简单
    会议记录 简单
    第一章 :zabbix监控
    第七章 :分布式监控与SNMP监控
    linux系统安装SNMP(可用)
  • 原文地址:https://www.cnblogs.com/jz-no-bug/p/14229804.html
Copyright © 2020-2023  润新知