<%@ 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");
%>
SID |
LNAME |
FNAME |
<%
while (rs.next()) {
String sid = rs.getString(1);
String lname = rs.getString(2);
String fname = rs.getString(3);
%>
<%= sid%> |
<%= lname%> |
<%= fname%> |
<% }
rs.close();
stmt.close();
conn.close();
%>
<%
} catch (Exception e) {
%>
Begin Exception Dump
<%
e.getMessage();
e.printStackTrace();
%>
<%= e %>
End Exception<%
}
%>