<%@ page import="java.sql.*, javax.sql.*, oracle.jsp.dbutil.ConnCacheBean" %> <% String connStr=request.getParameter("connStr"); if (connStr==null) { connStr=(String)session.getValue("connStr"); } else { session.putValue("connStr",connStr); } if (connStr==null) { %> <% } %> SimpleQuery JSP

Hello <%= (request.getRemoteUser() != null? ", " + request.getRemoteUser() : "") %> ! I'm Connection Cache Bean Demo JSP.


I do a basic JDBC query to get employee data from the EMP table in schema SCOTT. The connection is obtained from the connection cache.

<% try { Connection conn = ccbean.getConnection(); Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT ename, sal " + "FROM scott.emp ORDER BY ename"); if (rset.next()) { %> <% while (rset.next()) { %> <% } %>
Employee Name Salary
<%= rset.getString(1) %> $<%= rset.getDouble(2) %>
<%= rset.getString(1) %> $<%= rset.getDouble(2) %>
<% } else { %>

Sorry, the query returned no rows!

<% } rset.close(); stmt.close(); conn.close(); } catch (SQLException e) { out.println("

" + "There was an error doing the query:"); out.println ("

" + e + "
\n

"); } %>