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

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


I'm using a bean for database access and I'm querying the DEPT and EMP tables in schema SCOTT. I get all employees who work in the Research department.

<% try { String sql_string = " select ENAME from EMP,DEPT " + " where DEPT.DNAME = 'RESEARCH' " + " and DEPT.DEPTNO = EMP.DEPTNO"; // Make the Connection dbbean.connect(); // Execute the SQL and get a HTML table out.println(dbbean.getResultAsHTMLTable(sql_string)); // Close the Bean to close the connection dbbean.close(); } catch (SQLException e) { out.println("

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

" + e + "
\n

"); } %>