|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > getting data from an oracle db |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|