<%----------------------------------------------------------- Copyright 1999, Oracle Corporation. All rights reserved. ------------------------------------------------------------%> <%@ page import = "java.sql.*,oracle.xml.sql.query.OracleXMLQuery" %> The XMLQuery Demo

XMLQuery Demo

Employee List in XML

(View Page Source in your browser to see XML output) <% 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 = request.getParameter("connStr"); if (dbURL == null) { if (System.getProperty("oracle.jserver.version") != null) { dbURL = "jdbc:oracle:kprb:@"; } else { %> <% } } 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); %>
 <%=   xq.getXMLString()  %>  
<% } catch (java.sql.SQLException e) { %>

SQL error:

 <%= e %> 

<% } finally { if (stmt != null) stmt.close(); if (rset != null) rset.close(); if (conn != null) conn.close(); } %>