<%-----------------------------------------------------------
   Copyright © 1999, Oracle Corporation. All rights reserved.
------------------------------------------------------------%>

<%@ page import = "java.sql.*,oracle.xml.sql.query.OracleXMLQuery" %>
<html>
  <head><title> The XMLQuery Demo </title></head>
<body>
<h1> XMLQuery Demo  </h1>
<h2> Employee List in XML </h2>
<b>(View Page Source in your browser to see XML output)</b>
<% Connection conn = null;
   Statement stmt = null;
   ResultSet rset = null;
   try {

     String dbURL=request.getParameter("connStr");
     if (dbURL==null) {
       dbURL=(String)session.getValue("connStr");
     } else {
       session.putValue("connStr",dbURL);
     }
     if (dbURL==null) { %>
<jsp:forward page="../../sql/setconn.jsp" />
<%
     }

     DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
     conn = DriverManager.getConnection(dbURL, "scott", "tiger");
     stmt =  conn.createStatement ();
     rset = stmt.executeQuery ("SELECT ename, sal " + 
			       "FROM scott.emp ORDER BY ename");
     OracleXMLQuery xq = new OracleXMLQuery(conn, rset);  %>
       <PRE> <%=   xq.getXMLString()  %>  </PRE>
<%   } catch (java.sql.SQLException e) {  %>
         <P> SQL error: <PRE> <%= e %> </PRE> </P>
<%   } finally { 
         if (stmt != null) stmt.close();
         if (rset != null) rset.close();
         if (conn != null) conn.close(); 
     }  %>
</body>
</html>
