<%-----------------------------------------------------------
   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 {

     // determine JDBC driver name from session value
     // if null, use JDBC kprb driver if in JServer, JDBC oci otherwise
     String dbURL = (String)session.getValue("connStr");
     if (dbURL == null) 
       dbURL = (System.getProperty("oracle.jserver.version") == null?
		"jdbc:oracle:oci8:@" : "jdbc:oracle:kprb:@");

     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>
