Interactive Query

<%@ page import=" weblogic.db.jdbc.*, java.sql.* " %> <%! Connection conn = null; String jdbcClass = "weblogic.jdbc.jts.Driver"; String jdbcURL = "jdbc:cloudscape:demo"; public Connection getCon() { try { Class.forName(jdbcClass).newInstance(); conn = DriverManager.getConnection(jdbcURL); } catch (Exception e) {} return conn; } %> <% try { conn = getCon(); if (conn != null) { Statement stmt = conn.createStatement(); stmt.execute("select * from emp"); ResultSet ds = stmt.getResultSet(); String myURL = request.getRequestURI(); String person = request.getParameter("person"); if (person == null) { %> <% while (ds.next()) { String ename = "" + ds.getString("ename") + ""; %> <% } %>
Employee no Select a name Job Manager Date of hire Salary Commission Dept no
<%= ds.getString("empno") != null ? ds.getString("empno") : " " %> <%= ename %> <%= ds.getString("job") != null ? ds.getString("job") : " " %> <%= ds.getString("mgr") != null ? ds.getString("mgr") : " " %> <%= ds.getString("hiredate") != null ? ds.getString("hiredate") : " " %> <%= ds.getString("sal") != null ? ds.getString("sal") : " " %> <%= ds.getString("comm") != null ? ds.getString("comm") : " " %> <%= ds.getString("deptno") != null ? ds.getString("deptno") : " " %>
<% ds.close(); conn.close(); out.flush(); } else { %>

Results of your interactive query:

You chose person: <%= person %> <% } } else { out.print("Sorry. Database is not available."); } } catch (Exception e) { out.print("Exception: " + e); } %>

Copyright (c) 1999 by BEA Systems, Inc. All Rights Reserved.