Class Not Found Exception
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Abhisek_Sinha
Posted On:   Tuesday, June 25, 2002 03:21 AM

I have a Windows NT 4.0 .I am running a servlet which connects to Oracle 8i server thru JDBC. The following piece of code gives an Exception that class not found. The same piece of code when run as an Application executes perfectly. Please help me out as soon as possible. public int updateDatabase(int roll,String name,String course) { try { String driver = "oracle.jdbc.driver.OracleDriver"; Class.forName(driver); Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@PUNDNT055:1521:WEBDB","pucsd","pucsd"); Statement stmt = connection.createStatement(); String query = "insert in   More>>

I have a Windows NT 4.0 .I am running a servlet which connects to Oracle 8i server thru JDBC.
The following piece of code gives an Exception that class not found. The same piece of code when run as an Application executes perfectly.
Please help me out as soon as possible.



			
public int updateDatabase(int roll,String name,String course) {

try {

String driver = "oracle.jdbc.driver.OracleDriver";

Class.forName(driver);

Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@PUNDNT055:1521:WEBDB","pucsd","pucsd");
Statement stmt = connection.createStatement();
String query = "insert into student values(" + roll + "," + name + "," + course + ")";

stmt.executeUpdate(query);

return 0;

}

catch(ClassNotFoundException cnfe) {

return 1;

}

catch(SQLException sqle){

return 2;

}

}


   <<Less

Re: Class Not Found Exception

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, June 25, 2002 06:59 AM

If it is the oracle driver class that is not found, that probably is because you probably (?) did not add the classes12.jar to the WEBINF/lib directory of your web-application context.



If you were trying to use a jdbc datasource/connection pool provided by your J2EE container engine, you'd be using JNDI to look it up. Otherwise, if you are using your own, you have to provide the classes12.jar file yourself for it, in your web-app.



Probably the reason your standalone application works is that your standalone application uses a JVM whose CLASSPATH has a copy of the classes12.jar on it. But the j2ee servlet engine doesn't.

About | Sitemap | Contact