I am trying to access Oracle from JSP and my .jsp file is as below, I am getting class not found exception...am I missing something? I am using appropriate username,password,host and sid parameters.
<%@ page import="java.sql.*" %>
<HTML> <HEAD> <Title>Listing The Contents Of a Database Table</Title> </Head> <Body> <p>Content of the Employee Table: <Table Border=1 Cellpadding=0 Cellspacing=0> <TR> <TD> ID </TD> <TD> Name </TD> <TD> SSN </TD>
while (columns.next()) { int ID = columns.getInt("ID"); String Name = columns.getString("Name"); int SSN = columns.getInt("SSN");
%>
<TR> <TD> <%= ID %> </TD> <TD> <%= Name %> </TD> <TD> <%= SSN %> </TD>
</TR> <% } %> </Table> </Body> </HTML>
Purushoth Thambu
Ranch Hand
Joined: May 24, 2003
Posts: 425
posted
0
From JSP print the system.getProperty("java.class.path" is see if the classes12.jar or ojdbc.jar is in the classpath. If not add the jar file to the WEB-INF\lib directory.
Rahul Bajaj
Ranch Hand
Joined: Sep 21, 2004
Posts: 45
posted
0
How can I do that? Can you be more specific?
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
Originally posted by Miki Nema: class not found exception
In your case, of course this is the code that triggers it:
The jsp code is correct; your execution environment is wrong. In standalone applications, this is resolved by setting the CLASSPATH environment variable (not to be confused with PATH); in an IDE, it's usually resolved by configuring a classpath within the IDE specific to the project, and (in what is probably your case) within a J2EE application, the jar (or zip) is placed in a standard location for application libraries, commonly [application root]/WEB-INF/lib/
BTW, most experienced J2EE developers seperate their database code from their user interface code, keeping the former in regular java class files and the latter in JSPs (and supporting class files).
Rahul Bajaj
Ranch Hand
Joined: Sep 21, 2004
Posts: 45
posted
0
I have included ojdbc14.jar in my classpath but still getting the same error?
Purushoth Thambu
Ranch Hand
Joined: May 24, 2003
Posts: 425
posted
0
Just add below line in your jsp where you are making JDBC connection to oracle.
and check the classpath location. Make sure the jar file is in your WEB-INF\lib folder.It's better to test this way rather than including in the classpath. I am not sure if the classpath is same in the webapp server you are using.
Rahul Bajaj
Ranch Hand
Joined: Sep 21, 2004
Posts: 45
posted
0
My classpath location gives this output. But it doesn't show anything like WEB-INF/lib too??//