<span style="font-size:14px;">
<%@ page language="java" import="java.sql.*,java.io.*,java.util.*"%>
<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="com.oracle.enjoyshop.base.ConnectionFactory" %> /*引用数据库连接类*/
<%@ page import="com.oracle.enjoyshop.util.JDBCUtil" %> /*引用资源关闭类*/
<html>
<head>
<title>从数据库中的某个表拿到该表所有的数据</title>
<style type="text/css">
table {
border: 2px #CCCCCC solid;
width: 360px;
}
td,th {
height: 30px;
border: #CCCCCC 1px solid;
}
</style>
</head>
<body>
<%
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
conn = ConnectionFactory.getConnection();
String findSQL = "select u_id,u_name,u_pwd,u_tel,u_email,u_birthday,u_money from zzl_user ";
pstmt = conn.prepareStatement(findSQL);
rs=pstmt.executeQuery();
%>
<br>
<br>
<table align="center">
<tr>
<th>
<%
out.print("ID");
%>
</th>
<th>
<%
out.print("NAME");
%>
</th>
<th>
<%
out.print("PWD");
%>
</th>
<th>
<%
out.print("TEL");
%>
</th>
<th>
<%
out.print("EMAIL");
%>
</th>
<th>
<%
out.print("BRITH");
%>
</th>
<th>
<%
out.print("MENOY");
%>
</th>
</tr>
<%
while (rs.next()) {
%>
<tr>
<td>
<%
out.print(rs.getLong(1));
%>
</td>
<td>
<%
out.print(rs.getString(2));
%>
</td>
<td>
<%
out.print(rs.getString(3));
%>
</td>
<td>
<%
out.print(rs.getString(4));
%>
</td>
<td>
<%
out.print(rs.getString(5));
%>
</td>
<td>
<%
out.print(rs.getDate(6));
%>
</td>
<td>
<%
out.print(rs.getDouble(7));
%>
</td>
</tr>
<%
}
%>
</table>
<%
JDBCUtil.close(conn, pstmt, stmt, rs);
%>
</body>
</html>
截图:
ID | NAME | PWD | TEL | BRITH | MENOY | |
---|---|---|---|---|---|---|
1000 | 张三 | 123456 | 15802561844 | 1916911795@qq.com | 1996-05-21 | 1000.0 |
1020 | 李四 | 654321 | 15802561844 | 1916911795@qq.com | 2001-05-20 | 1000.0 |