• Java web find_stu_1.jsp


    <%@ page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>显示所有学生的页面</title>
    </head>
    <body>
    <center>
    <%
    request.setCharacterEncoding("UTF-8");
    String driverName= "com.mysql.jdbc.Driver";
    String userName="root";
    String userPwd="147258369";
    String dbName="students";
    String url1="jdbc:mysql://localhost:3306/"+dbName;
    String url2="?user="+userName+"&password="+userPwd;
    String url3="&useUnicode=true&characterEncoding=UTF-8";
    String url=url1+url2+url3;
    Class.forName(driverName);
    Connection conn=DriverManager.getConnection(url);

    String sql="select * from students_info";
    PreparedStatement pstmt=conn.prepareStatement(sql);
    ResultSet rs=pstmt.executeQuery();
    rs.last();
    %>你要查询的学生数据表中共有
    <font size="5" color="red"> <%=rs.getRow()%></font>人
    <table border="2" bgcolor="ccceee" width="650">
    <tr bgcolor="CCCCCC" align="center">
    <td>记录条数</td> <td>学号</td> <td>姓名</td>
    <td>性别</td> <td>年龄</td><td>体重</td><td>身高</td>
    </tr>
    <% rs.beforeFirst();
    while(rs.next()){
    %> <tr align"center">
    <td><%=rs.getRow() %>
    <td><%=rs.getString("id") %></td>
    <td><%=rs.getString("name") %></td>
    <td><%=rs.getString("sex") %></td>
    <td><%=rs.getString("age") %></td>
    <td><%=rs.getString("weight") %></td>
    <td><%=rs.getString("hight") %></td>
    </tr>
    <% } %>
    </table>
    </center>
    <%if(rs!=null){ rs.close();}
    if(pstmt!=null){pstmt.close();}
    if(conn!=null){conn.close();}
    %>
    </body>
    </html>

  • 相关阅读:
    正则匹配任意字(包括换行符)
    linux终端光标的快捷键操作
    正则向前查找和向后查找
    正则表达式软件Expresso
    JsonP 跨域完全解析
    PHP代码阅读Phpxref
    ubuntu 操作用户名和密码
    curl多线程解释[转]
    php递归创建多级目录
    离散数学 第一章 命题逻辑 11 命题及其表示法
  • 原文地址:https://www.cnblogs.com/meng2/p/7719233.html
Copyright © 2020-2023  润新知