• 2021.5.17


    index:

    <%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%>
    <%@ page errorPage="error.jsp"%>
    <html>
    <head>
    <title>学生管理系统</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>
    <h1>学生管理系统</h1>
    <a href="add.jsp">添加学生信息</a>
    <br />
    <br />
    <table style=" 50%;">
    <tr>
    <th>学号</th>
    <th>姓名</th>
    <th>性别</th>
    <th>出生年月</th>
    <th>家庭住址</th>
    </tr>
    <%
    try {
    Class.forName("com.mysql.cj.jdbc.Driver");
    Connection con = DriverManager.getConnection(
    "jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false",
    "root", "123456");
    //使用Statement对象
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("select * from studentinfo");

    /*
    PreparedStatement stmt = con.prepareStatement("select * from bookinfo");
    ResultSet rs = stmt.executeQuery();
    */
    while (rs.next()) {
    int id = rs.getInt(1);
    out.println("<tr><td>" + id + "</td><td>" + rs.getString(2) + "</td><td>" + rs.getString(3) + "</td><td>"
    + rs.getString(4) + "</td><td>" + rs.getString(5) + "</td><td>" + "<a href='edit.jsp?id=" + id
    + "'>修改</a>&nbsp;<a href='del.jsp?id=" + id + "'>删除</a></td></tr>");
    }
    rs.close();
    stmt.close();
    con.close();
    } catch (Exception e) {
    out.println("Exception:" + e.getMessage());
    }
    %>

    </table>
    <br />
    <hr />
    <div
    style="text-align: center; 100%; font-size: 12px; color: #333;">

    </div>
    </body>
    </html>

    <%@ page language="java" isErrorPage="true" pageEncoding="utf-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>error page</title>
    </head>
    <body>
    错误信息为:<br/>
    <%=exception.getMessage()%><br>
    <%=exception.toString()%>
    </body>
    </html>

  • 相关阅读:
    Python冒泡算法和修改配置文件
    第五章:处理数据
    第四章:持久存储
    Python之打印99乘法表
    Python之编写登录接口
    Python之文件操作
    第三章:文件与异常
    FineUI 修改config表属性
    FineUI Grid中WindowField根据列数据决定是否Enalble
    表之间不同字段的数据复制
  • 原文地址:https://www.cnblogs.com/SirNie/p/14909413.html
Copyright © 2020-2023  润新知