<%@ include file="setupcache.jsp" %>
<%@ page import="java.sql.*, javax.sql.*, oracle.jdbc.pool.*" %>

<!------------------------------------------------------------------
 * This is a JavaServer Page that uses Connection Caching over application
 * scope. The Cache is created in an application scope in setupcache.jsp.
 * Connection is ontained from the Cache and recycled back once done.
--------------------------------------------------------------------!>

<HTML> 
  <HEAD> 
    <TITLE>
	ConnCache2 JSP
    </TITLE>
  </HEAD>
 <BODY BGCOLOR=EOFFFO> 
 <H1> Hello 
  <%= (request.getRemoteUser() != null? ", " + request.getRemoteUser() : "") %>
 !  I am Connection Caching JSP.
 </H1>
 <HR>
 <B> I get the Connection from the Cache and recycle it back.
 </B> 

 <P>
<%
    try {
      Connection conn = cods.getConnection();
 
      Statement stmt = conn.createStatement ();
      ResultSet rset = stmt.executeQuery ("SELECT User from dual");
      if (rset.next()) {
%>
      <P> Hi, <%= rset.getString(1) %> </P>
<%    }
      else  {
%>     
      <P> Sorry, i don't know who you are  </P>
<%
      }
      rset.close();
      stmt.close();
      conn.close();  // Put the Connection Back into the Pool

    } catch (SQLException e) {
      out.println("<P>" + "There was an error doing the query:");
      out.println ("<PRE>" + e + "</PRE> \n <P>");
    }
%>

 </BODY>
</HTML>
