<%@ page import="java.sql.*" %>

JSP Example

Querying STUDENTS table

<% // try { //Class.forName("oracle.jdbc.driver.OracleDriver").newInstance(); Class.forName("oracle.jdbc.driver.OracleDriver"); java.sql.Connection conn; conn = DriverManager.getConnection( "jdbc:oracle:thin:@tinman.cs.gsu.edu:1521:sid9ir2","book","book"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select * from students"); %> <% while (rs.next()) { String sid = rs.getString(1); String lname = rs.getString(2); String fname = rs.getString(3); %> <% } rs.close(); stmt.close(); conn.close(); %>
SID LNAME FNAME
<%= sid%> <%= lname%> <%= fname%>
<% } catch (Exception e) { %> Begin Exception Dump

<% e.getMessage(); e.printStackTrace(); %> <%= e %>

End Exception<% } %>