%@page language="java" %>
<%@page import="java.sql.*" %>
Test
Testing
<%!
// Basic declarations
String DRIVER = "oracle.jdbc.driver.OracleDriver";
String URL = "jdbc:oracle:thin:@unixapps1.wright.edu:1521:ORA2";
String USERNAME = "YOUR USERNAME";
String PASSWORD = "YOUR PASSWORD";
java.sql.Connection conn;
java.sql.Statement st;
java.sql.ResultSet rec;
%>
<%
try {
Class.forName(DRIVER); // Allocate the driver class
conn = DriverManager.getConnection(URL, USERNAME, PASSWORD); // Make a connection
st = conn.createStatement(); // Create the statement
String SQL = "SELECT * FROM lab6_Student"; // Build the SQL
rec = st.executeQuery(SQL); // Execute the SQL
%>
| SID | Name |
<%
while(rec.next()) {
%>
| <%=rec.getString("sid") %> | <%=rec.getString("sname")%> |
<%
}
%>
<%
} catch(Exception e) {
out.println("Exception: " + e + "Occurred in: " +
e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber() + "
");
// You can comment out the following line to not go the 500 server error page.
throw e;
} finally {
// Make sure you close only things you have opened!
if (rec!=null) rec.close();
if (st !=null) st.close();
if (conn !=null) conn.close();
}
%>