Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.sql.*" %>
- <html>
- <head><title>JSP PART A - LAB 9</title></head>
- <body>
- <p>Displays course information for course numbers less than 100</p>
- <%
- out.println("Program: part1.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 stringQuery = ("SELECT description, cost, prerequisite, created_by, created_date, modified_by, modified_date FROM course WHERE course_no <100");
- PreparedStatement preState = conn.prepareStatement(stringQuery);
- ResultSet rset = preState.executeQuery();
- out.println("Description, Cost, Prerequsite<br>");
- while(rset.next())
- out.println(rset.getString("description") + ", " + rset.getString("cost") + " ," + rset.getString("prerequisite") + "<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