Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error with Tomcat connecting to Oracle???

Status
Not open for further replies.

lnewsome

Technical User
May 9, 2001
3
0
0
US
I'm trying to make a simple connection to Oracle. I have configured Tomcat to create/connect a JDBCrealm and the connection works, or at least seems to load with no errors..

However, anytime I try to declare any variables i get the same error:

org.apache.jasper.JasperException: Unable to compile class for JSP/usr/local/jakarta-tomcat-3.2.4/work/localhost_8080/_0002ftest_0002ejsptest_jsp_13.java:19: Exception java.sql.SQLException can't be thrown in initializer.
Connection conn = DriverManager.getConnection("jdbc:eek:racle:thin:mad:testmachine:1521:SID", "scott", "tiger");


How can I fix this??? Here is the example code (which seems to be published all over the web as an example):

<%@ page language=&quot;java&quot; import=&quot;java.sql.*&quot; %>


<%! Connection conn = DriverManager.getConnection(&quot;jdbc:eek:racle:thin:mad:testmachine:1521:SID&quot;, &quot;scott&quot;, &quot;tiger&quot;);%>

Finally, make a query and display the results:
<% Statement statement =
conn.createStatement();
ResultSet resultSet =
statement.executeQuery(&quot;select * from emp&quot;); %>
<P> The results are:
</P>
<UL>
<% while (resultSet.next()) { %>
<LI><%= resultSet.getString(1) %></LI>
<% } >
</UL>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top