%@ page import="java.sql.*, javax.sql.*, oracle.jdbc.pool.*" %>
<%
String connStr=request.getParameter("connStr");
if (connStr==null) {
connStr=(String)session.getValue("connStr");
} else {
session.putValue("connStr",connStr);
}
if (connStr==null) { %>
<% try { ods.setURL(connStr); ods.setUser("scott"); ods.setPassword("tiger"); Connection conn = ods.getConnection (); Statement stmt = conn.createStatement (); ResultSet rset = stmt.executeQuery ("SELECT ename, sal " + "FROM scott.emp ORDER BY ename"); if (rset.next()) { %>
Employee Name | Salary |
---|---|
<%= rset.getString(1) %> | $<%= rset.getDouble(2) %> |
<%= rset.getString(1) %> | $<%= rset.getDouble(2) %> |
Sorry, the query returned no rows!
<% } rset.close(); stmt.close(); conn.close(); // Put the Connection Back into the Pool } catch (SQLException e) { out.println("" + "There was an error doing the query:"); out.println ("
" + e + "\n
"); } %>