您的位置:首页 > 数据库 > Oracle

如何在JSP页面显示Oracle数据库内容

2017-08-08 19:56 351 查看
<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>

     截图:

IDNAMEPWDTELEMAILBRITHMENOY
1000张三123456158025618441916911795@qq.com1996-05-211000.0
1020李四654321158025618441916911795@qq.com2001-05-201000.0
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: