如何在JSP页面显示Oracle数据库内容
展开全部
<span style="font-size:12px;">
<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>
<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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询