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="jdbcracle: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;
}
}
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="jdbcracle: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;
}
}