<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> Insert title here <% try{ Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://localhost:3306/edu?"+"useUnicode=true&characterEncoding=utf-8"; String user="root"; String password="1009"; Connection con=DriverManager.getConnection(url,user,password); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from student"); while(rs.next()){ %> <% } rs.close(); stmt.close(); con.close(); }catch(Exception e){ e.printStackTrace(); } %>
user name password sex national telephone age
<%=rs.getString("user") %> <%=rs.getString("name") %> <%=rs.getString("password") %> <%=rs.getString("sex") %> <%=rs.getString("national") %> <%=rs.getString("telephone") %> <%=rs.getString("age") %>