标签:03 getString rs stmt 20245.05 nbsp close con
学习时间 |
1h |
代码行数 |
30行 |
博客量 |
1篇 |
学习内容 |
<%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%>
<html> <head> <title>学生信息管理系统</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <h1 style="width: 100%; font-family: 微软雅黑; color:#fff;">学生信息管理系统</h1> <a href="add.jsp">添加学生信息</a> <br /> <br /> <table style="width: 50%;"> <tr> <th>学号</th> <th>姓名</th> <th>性别</th> <th>生日</th> <th>管理</th> </tr> <% try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/gs?useUnicode=true&characterEncoding=utf-8", "root", "123456"); //使用Statement对象 Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from student"); while (rs.next()) { int id = rs.getInt(1); out.println("<tr><td>" + rs.getString(1) +"</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> <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; width: 100%; font-size: 12px; color: #333;"> ©版权所有:石家庄铁道大学信息科学与技术学院 <a href="Lab03.png" target="_blank">网站地图</a> </div> </body> </html>
|
|
|
标签:03,
getString,
rs,
stmt,
20245.05,
nbsp,
close,
con
From: https://www.cnblogs.com/dmx-03/p/18205932