zoukankan      html  css  js  c++  java
  • 信息查找界面

    <%@ 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 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);
             
        }
    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>
     
     
    </body>
    </html>
  • 相关阅读:
    如何判断单链表是否存在环
    语法面试等题目汇总
    数据分析师常见的10道面试题解答
    Python 的函数
    Python 的错误和异常处理
    Python 的条件语句和循环语句
    Python 的基本运算和内置函数
    Python 的数据表示
    Python 基础
    关于 Python
  • 原文地址:https://www.cnblogs.com/9635741zly/p/14916692.html
Copyright © 2011-2022 走看看