#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    8
    Rep Power
    0

    getting data from an oracle db


    I searched this forum and came up with some code that I'm trying to make work for me.

    I'm running oracle 8 1 7 with 9ias.

    I'm trying to just drop this in a jsp and run it from htdocs. Do I need to make sure that there are some drivers downloaded onto my machine or something along those lines?

    Here's my error:

    Request URI:/test2.jsp



    Exception:
    oracle.jsp.provider.JspCompileException: Errors compiling:c:\oracle\ora9ias\apache\apache\htdocs\_pages\\_test2.javac:\oracle\ora9ias\apache\apache\ htdocs\_pages\_test2.java:93: '}' expected.
    }
    ^
    c:\oracle\ora9ias\apache\apache\htdocs\_pages\_test2.java:94: 'try' without 'catch' or 'finally'.
    private static class __jsp_StaticText {
    ^
    c:\oracle\ora9ias\apache\apache\htdocs\_pages\_test2.java:94: Statement expected.
    private static class __jsp_StaticText {
    ^
    3 errors

    Here's my jsp.




    <%@ page import="java.sql.*" %>
    <HTML>
    <HEAD><TITLE>Simple Oracle Example</TITLE></HEAD>
    <BODY BGCOLOR="#FFFFFF">
    <CENTER>
    <B>Employees</B>
    <BR><BR>

    <%
    Connection conn = null;
    try
    {
    Class.forName("oracle.jdbc.driver.OracleDriver");

    conn = DriverManager.getConnection(
    "jdbcracle:thin:@HOST:PORT:SID",
    "scott",
    "tiger");

    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT * FROM Example.Emp");

    //Print start of table and column headers
    out.println("<TABLE CELLSPACING=\"0\" CELLPADDING=\"3\" BORDER=\"1\">");
    out.println("<TR><TH>ID</TH><TH>NAME</TH></TR>");

    //Loop through results of query.
    while(rs.next())
    {
    out.println("<TR>");
    out.println("<TD>" + rs.getString("EmpID") + "</TD>");
    out.println("<TD>" + rs.getString("Name") + "</TD>");
    out.println("</TR>");
    }

    out.println("</TABLE>");
    }
    catch(SQLException e)
    {
    out.println("SQLException: " + e.getMessage() + "<BR>");
    while((e = e.getNextException()) != null)
    out.println(e.getMessage() + "<BR>");
    }
    catch(ClassNotFoundException e)
    {
    out.println("ClassNotFoundException: " + e.getMessage() + "<BR>");
    }
    finally
    {
    //Clean up resources, close the connection.
    if(conn != null)
    {
    try
    {
    conn.close();
    }
    catch (Exception ignored) {}
    }
    }
    %>

    </CENTER>
    </BODY>
    </HTML>
  2. #2
  3. No Profile Picture
    Moderator =(8^(|)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2002
    Location
    Sacramento, CA
    Posts
    1,710
    Rep Power
    14
    It looks like one too many {'s, but damned if I can find one.

    Can you find the servlet that oracle generated from your jsp? Then you could actually look at line 93 and see what it was complaining about.

IMN logo majestic logo threadwatch logo seochat tools logo