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

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


I'm using a cursor bean with PL/SQL to query department names from the DEPT table in schema SCOTT.

<% try { // Make the Connection connbean.connect(); String sql = "BEGIN OPEN ? FOR SELECT DNAME FROM DEPT; END;"; // Create a Callable Statement cursorbean.create ( connbean, CursorBean.CALL_STMT, sql); cursorbean.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CURSOR); // Execute the PLSQL cursorbean.executeUpdate (); // Get the Ref Cursor ResultSet rset = cursorbean.getCursor(1); out.println(oracle.jsp.dbutil.BeanUtil.translateToHTMLTable (rset)); // Close the RefCursor rset.close(); // Close the Bean cursorbean.close(); // Close the connection connbean.close(); } catch (SQLException e) { out.println("

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

" + e + "
\n

"); } %>