日期:2014-05-17 浏览次数:20661 次
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page 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> <table border="1" width="500" align="center"> <caption><h1>产品列表</h1></caption> <tr> <th>姓名</th> <th>电话号码</th> <th>性别</th> <th>email</th> <th>分类</th> </tr> <% Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123"); PreparedStatement ps=con.prepareStatement("select * from product"); ResultSet rs=ps.executeQuery(); while(rs.next()){ %> <tr> <!-- <td><%out.println(rs.getInt("id")); %></td> --> <td><%=rs.getInt("id") %></td> <td><%out.println(rs.getString("name")); %></td> <td><%out.println(rs.getString("type"));%></td> <td><%out.println(rs.getFloat("price"));%></td> <td><%out.println(rs.getString("company"));%></td> </tr> </table> </body> </html>