Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.sql.*" %>
- <html>
- <head><title>JSP PART B - LAB 9</title></head>
- <body>
- <p>an instructor last name & returnt he courses they teach</p>
- <%
- out.println("Program: partb.jsp <br>");
- try {
- Class.forName("oracle.jdbc.OracleConnection");
- out.println("Driver loaded <br>");
- }
- catch (ClassNotFoundException e) {
- out.println("Could not load the driver <br>");
- }
- String user = "N01125338";
- String passwd = "oracle";
- try {
- Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@munro.humber.ca:1521:msit", user, passwd);
- out.println("Database connected <br><br>");
- String name = request.getParameter("value1");
- String stringQuery = ("SELECT i.instructor_id, i.last_name, s.course_no,c.description FROM instructor i, section s, course c WHERE i.instructor_id = s.instructor_id AND s.course_no = c.course_no AND i.last_name = ?");
- PreparedStatement preState = conn.prepareStatement(stringQuery);
- preState.setString(1, name);
- ResultSet rset = preState.executeQuery();
- out.println("Course Number, Course Name <br>");
- while(rset.next())
- out.println(rset.getString("course_no") + ", " + rset.getString("description") + "<br>" );
- preState.close();
- }
- catch (SQLException e) {
- out.println("Could not make Oracle connection");
- }
- %>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement