FileDocCategorySizeDatePackage
OCCIConnectionServlet.javaAPI DocExample2035Tue Nov 21 14:19:54 GMT 2000None

OCCIConnectionServlet

public class OCCIConnectionServlet extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  out.println("<html>");
  out.println("<head>");
  out.println("<title>Oracle Cached Connection " + 
   "Implementation Test Servlet</title>");
  out.println("</head>");
  out.println("<body>");

  // let's turn on verbose output
  OCCIConnection.setVerbose(true);
  // now let's get a cached connection
  Connection connection = OCCIConnection.checkOut();
  
  Statement  statement  = null;
  ResultSet  resultSet  = null;
  String     userName   = null;  
  try { 
   // test the connection
   statement = connection.createStatement();
   resultSet = statement.executeQuery(
    "select initcap(user) from sys.dual");
   if (resultSet.next())
    userName = resultSet.getString(1);
  }
  catch (SQLException e) {
   out.println("DedicatedConnection.doGet() SQLException: " + 
    e.getMessage() + "<p>");
  }
  finally {
   if (resultSet != null) 
    try { resultSet.close(); } catch (SQLException ignore) { }
   if (statement != null) 
    try { statement.close(); } catch (SQLException ignore) { }
  }

  // let's add a little delay so we can force 
  // multiple connections in the connection cache
  for (int o=0;o < 3;o++) {
   for (int i=0;i < 2147483647;i++) {}
  }

  // let's return the conection
  OCCIConnection.checkIn(connection);

  out.println("Hello " + userName + "!<p>");
  out.println("You're using an Oracle Cached " +  
   "Connection Implementation connection!<p>");
  out.println("</body>");
  out.println("</html>");
 
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

  doGet(request, response);