jdbc ClassNotFoundException

J

James

I get the following stace trace when I try to run my servlet

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1352)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1198)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at database.DatabaseConnection.<init>(DatabaseConnection.java:16)
at bussiness.Item.save(Item.java:118)
at rmit.addItem.doPost(addItem.java:198)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126
)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105
)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processC
onnection(Http11BaseProtocol.java:667)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.jav
a:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWo
rkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:684)
at java.lang.Thread.run(Thread.java:595)


Here is my code minus username password and db url. Any Ideas how to fix the
error?

I have tried importing oracle.jdbc.driver.*; and running
Class.forName("OracleDriver"); and
Class.forName("oracle.jdbc.driver.OracleDriver");

package database;
import java.sql.*;
import java.io.*;
import java.util.*;
import oracle.jdbc.driver.*;

public class DatabaseConnection
{
private Connection conn;
private static final String username="....";
private static final String password="...";
private static final String url="jdbc:eek:racle:thin:.....:...:....";


public DatabaseConnection() throws SQLException, ClassNotFoundException
{
Class.forName("OracleDriver"); /*oracle.jdbc.driver.OracleDriver*/
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn=DriverManager.getConnection(url,username,password);
}

public ResultSet runQuery(String sql) throws SQLException
{
Statement statement = conn.createStatement();
ResultSet records=statement.executeQuery(sql);
return records;
}

public void runUpdate(String sql) throws SQLException
{
Statement statement = conn.createStatement();
statement.execute(sql);

}

public void close() throws SQLException
{
conn.close();
}

public Object runSingleValue(String sql) throws SQLException
{
System.out.println("a");
Object value=null;
System.out.println("b");
ResultSet rs=runQuery(sql);
System.out.println("c");
if(rs.next())
{
System.out.println("d");
value=rs.getObject(1);
}
System.out.println("e");
rs.close();
System.out.println("f");
return value;
}

}
 
?

=?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=

you should put your jdbc drivers into web-inf dictionary

Or you can put them in shared/lib directory, if you
belive that there are more applications to use them.

DG
 
C

Chris Smith

you should put your jdbc drivers into web-inf dictionary

That should be WEB-INF rather than web-inf (it matters on platforms with
case-sensitive filesystems), and you can put them in WEB-INF/lib if they
are JAR files, or an appropriate package-mirroring directory structure
under WEB-INF/classes if they are loose class files. The second case is
unlikely, unless you're writing your own drivers.

Placing JDBC drivers in a shared code directory of the web container is
a good idea when and only when the JDBC driver contains native code
(such as Oracle's OCI driver). Otherwise, it would be unnecessarily
tying the application to the setup of the web container, and should be
avoided because of the extra deployment and administration hassle.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top