NoClassDefFoundError: oracle/jdbc/OracleDriver
I have a servlet that is supposed to connect to an oracle database select from a table and then return the results. This works in JDeveloper but when I try to deploy it to tomcat I get an error saying the following.
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at LoginServlet.doPost(LoginServlet.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
How can I resolve this problem ?
I have the same problem.
I wrote a simple program as follows.
import java.sql.*;
import oracle.jdbc.*;
import oracle.sql.*;
public class OracleConnect
public static void main (String args []) throws SQLException
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@10.0.0.8:1521:ORCL","scott","tiger");
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT ename FROM emp");
while (rset.next ())
System.out.println (rset.getString (1));
rset.close();
stmt.close();
conn.close();
I am compiling like this.
C;>javac -classpath c:\oracle\ora92\jdbc\lib\classes12.jar;c:\oracle\ora92\jdbc\lib\nls_charset12.jar;. OracleConnect.java
Everything is fine upto now.
But at the time of execution
C:\>java OracleConnect
Java is crying like this.
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDri
ver at OracleConnect.main(OracleConnect.java:11)
Can any one help me to resolve this issue please? By the way, I did not install Jdeveloper. I am using command prompt to do the stuff.
Thanks,
Similar Messages
-
Java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
I am trying to connect from a servlet running in Tomcat on my desktop to an instance of Personal Oracle9i running on my desktop. I am gettiung NoClassDefFoundError. The code compiles.
I know it is a path issue but I am at a loss to figure out where. Tomcat does not find the driver however it is in my machines path.
Running following:
j2sdk1.4.1_02
Personal Oracle 9.2
Tomcat 4.1.29
Windows XP
I have added the location of Classes12.zip to the class path: .;c:\Sun\AppServer\lib\j2ee.jar;c:\Sun\AppServer\lib\j2ee-svc.jar;d:\oracle\ora92\jdbc\lib\classes12.zip;
The "root cause" of error is:
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at OOP.OracleConnectionDemo.doPost(OracleConnectionDemo.java:34)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
The code is as follows:
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.jdbc.OracleDriver;
//import oracle.jdbc.driver.*; //did not work either
public class OracleConnectionDemo extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException{
Connection con = null;
// Load the Oracle JDBC driver
try{
//two versions did not work
//DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver);
DriverManager.registerDriver(new OracleDriver());
con = DriverManager.getConnection
("jdbc:oracle:thin:@micron.1521:MCAP","scott","scott");
catch (SQLException e){
catch (Exception e){
finally{
try{
if (con != null)
con.close();
catch(SQLException ignored){
}//finally
}What you should be realizing is that Tomcat doesn't give a hoot about your system CLASSPATH. It totally ignores it. You really shouldn't even have one, because IDEs and app servers don't even take it into account. Get rid of it.
You're making lots of mistakes here:
(1) The Tomcat docs explicitly state that it won't look inside ZIP files. Change it to a JAR file.
(2) You're using JDK 1.4.1 and classes12.zip? You realize, of course, that there's an ojdbc14.jar available for download from Oracle. Go get it.
(3) Put the JDBC JAR in the WEB-INF/lib directory of your Web app. If you don't have one, you're not deploying your Web app properly.
(4) You've got Java code with empty catch blocks? That's one of the most foolish things a person can do. If an exception's thrown you'll never know it. For goodness sake, at least print the stack trace.
(5) Why do you have those Oracle imports? That ties your code to Oracle. The design of the java.sql package lets you use interfaces. Why don't you write JDBC the way it was meant to be written?
(6) Why aren't you setting up a JNDI data source?
% -
Java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
When I run java servlet test_ora.java with IE6.0 I get the following error page:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:376)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:518)
at java.lang.Thread.run(Thread.java:536)
root cause
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at test_ora.doGet(test_ora.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2349)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:646)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:469)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:644)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:483)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:376)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:518)
at java.lang.Thread.run(Thread.java:536)
Java Web Services Developer Pack/1.0-fcs
I thought it is about JDBC configuration. But when I run JdbcCheckup.java everything works fine. Can anybody help me, please?
test_ora.java looks like this:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class test_ora extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
String str_dok_numer, str_f_inkraft;
int int_dok_wal_id;
Connection conn=null;
Statement s = null;
response.setContentType("text/html;charset=iso-8859-2");
PrintWriter out = response.getWriter();
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@192.168.15.2:1521:DB2","janusz","kimono");
s = conn.createStatement();
} catch (SQLException e) {
out.println("Blad polaczenia z baza danych: " + e.getMessage());
try {
ResultSet r =s.executeQuery("select dok_numer, f_inkraft, dok_wal_id from gndlf_umowy_inkraft");
out.println("DOK_NUMER\tF_INKRAFT\tDOK_WAL_ID");
while(r.next()){
out.println (r.getString (1) +"\t" + r.getString (2) + "\t" +r.getString (3));
conn.close();
} catch (Exception e) {
out.println("Wystapil problem z wyslaniem SQL do bazy danych: " + e.getMessage());
finally {
try { conn.close(); }
catch(SQLException e) {}
and here is code for JdbcCheckup.java (I get it from Internet and made some modifications):
* This sample can be used to check the JDBC installation.
* Just run it and provide the connect information. It will select
* "Hello World" from the database.
// You need to import the java.sql package to use JDBC
import java.sql.*;
// We import java.io to be able to read from the command line
import java.io.*;
class JdbcCheckup {
public static void main(String args[])
throws SQLException, IOException
// Load the Oracle JDBC driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// Prompt the user for connect information
System.out.println("Please enter information to test connection to the database");
String user;
String password;
String database;
user = readEntry("user: ");
int slash_index = user.indexOf('/');
if (slash_index != -1)
password = user.substring(slash_index + 1);
user = user.substring(0, slash_index);
else
password = readEntry("password: ");
database = readEntry("database(a TNSNAME entry): ");
System.out.print("Connecting to the database...");
System.out.flush();
System.out.println("Connecting...");
//Connection conn = DriverManager.getConnection("jdbc:oracle:oci8:@" + database, user, password);
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.15.2:1521:" + database, user, password);
System.out.println("connected!!!");
// Create a statement
Statement stmt = conn.createStatement();
// Do the SQL "Hello World" thing
ResultSet rset = stmt.executeQuery("select 'Hello World' from dual");
while (rset.next())
System.out.println(rset.getString(1));
// close the result set, the statement and connect
rset.close();
stmt.close();
conn.close();
System.out.println("Your JDBC installation is correct.");
// Utility function to read a line from standard input
static String readEntry(String prompt)
try
StringBuffer buffer = new StringBuffer();
System.out.print(prompt);
System.out.flush();
int c = System.in.read();
while (c != '\n' && c != -1)
buffer.append((char)c);
c = System.in.read();
return buffer.toString().trim();
catch(IOException e) {
return "";
I use Java Web Service Developer Pack 1.0 on Win98 SE, database Oracle 8.1.7 is installed on dedicated IBM server (AIX 4.x).
I put these lines in autoexec.bat:
set PATH=C:\Perl\bin\;"C:\j2sdk1.4.0\bin";%PATH%
set CLASSPATH=.;C:\j2sdk1.4.0\lib\tools.jar;C:\j2sdk1.4.0\lib\classes12.zip;C:\j2sdk1.4.0\lib\classes111.zip;%CLASSPATH%
set CLASSPATH=C:\jwsdp_1_0\common\lib\servlet.jar;C:\jwsdp_1_0\common\lib\jasper-compiler.jar;C:\jwsdp_1_0\common\lib\jasper-runtime.jar;%CLASSPATH%
set JAVA_HOME=C:\j2sdk1.4.0I have the same problem. I created a JSP page that uses a class to retrieve database information. I added a main method to the class so I would be able to test it. When I test the class using the main method the method returns all the information from the database. When I try it using Tomcat, I get the following error: java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
Does anyone have an idea of what is going on?
My CLASSPATH configuration is the same. -
hi,
I try a simple connect to a DB 9.2.0.1
through JDBC
$javac -d /home/oracle/jdbc Applet1.java
OK
but ...
oracle@pluto:/home/oracle/jdbc$ appletviewer -J-Djava.security.policy=mypolic>
java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at mypackage.Applet1.connectToDB(Applet1.java:55)
at mypackage.Applet1.access$000(Applet1.java:17)
at mypackage.Applet1$1.actionPerformed(Applet1.java:41)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1
64)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstr
ctButton.java:1817)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonMode
.java:419)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:25
private void connectToDB(ActionEvent e) {
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver())
con = DriverManager.getConnection ("jdbc:oracle:thin:@pluto:1521:DB
9IDEV","system","manger");
empValues.setText("Connected to the Database. Fetching Values from
TOTO Tables.\n");
fetchValues();
} catch (SQLException ex) {
System.out.println("Connection Error = " + ex.toString());
I tried with:
CLASSPATH=/tools/oracle/9.2.0/jdbc/lib/classes12.jar
and ( loaded from otn for JDK 1.4 and 9.2.0.1)
CLASSPATH=/tools/oracle/9.2.0/jdbc/lib/ojdbc14.jar
What I have to put in the CLASSPATH, please ???Please don't cross post.
http://forum.java.sun.com/thread.jsp?thread=541572&forum=57&message=2625798
http://forum.java.sun.com/thread.jsp?thread=541573&forum=48&message=2625800
http://forum.java.sun.com/thread.jsp?thread=541574&forum=31&message=2625802 -
A sign Applet unable to load "oracle.jdbc.OracleDriver" class
hi,
i am chiranjit , i am now working in a web based ERP. where i am using a signed applet which unable to load "oracle.jdbc.OracleDriver" class but it easily loading "sun.jdbc.odbc.JdbcOdbcDriver", i am also giving my code:
import java.sql.*;
import java.math.*;
import java.io.*;
import java.awt.*;
class JdbcTest extends Applet{
public static void main (String args[]) throws SQLException {
// Load Oracle driver
DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
// Connect to the local database
Connection conn =
DriverManager.getConnection
("jdbc:oracle:thin:@192.168.16.7:1521:kris",
"plsql", "oracle");
// Query the employee names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT FIRST_NAME FROM
AUTHORS");
// Print the name out
while (rset.next ())
System.out.println (rset.getString (1));
// Close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
}Hint: The sun.jdbc.odbc.JdbcOdbcDriver is available in any JRE distribution. The Oracle driver is not.
-
Java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
Hi everyone,
Can any one plz help me with this problem in connection with the database...im unable to connect from the servlet where my jdbc connectivity code is written when i compile it gives me this error:
Ljava.lang.String;@e53220java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java: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 shoppingcart.shoppingcartservlet.doit(shoppingcartservlet.java:83)
at shoppingcart.shoppingcartservlet.doPost(shoppingcartservlet.java:30)
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(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: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.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)Hi
The server is not able to load the jdbc driver path. Place your driver in server classpath
Venkat -
Connect to an Oracle database by using oracle.jdbc.OracleDriver: error
Hi,
I'm trying to connect to an Oracle database so we can retrieve notes of tables, views and packages.
By using the API of Data Modeler (transformation script) we want to add these notes to corresponding objects in Data Modeler.
I'm starting with this:
importPackage(java.lang);
importPackage(java.awt);
importPackage(java.sql);
java.lang.Class.forName("oracle.jdbc.OracleDriver");
An error occurs when I run this code:
It has to be a Java thing...
Anyone a suggestion?Problem solved! One of my colleagues referred to this post: Import user defined properties from Oracle Designer
More in detail: it's about this couple of lines:
// Copy the ojdbc6.jar file to ..\datamodeler-home\jlib directory
// Add this line to datamodeler.conf
// AddJavaLibFile ../../jlib/ojdbc6.jar
I changed my datamodeler.conf file, restarted DM and now there's no longer an error when I am trying to use the Oracle JDBC drive. -
I have the following configuration:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
on a Suse 10.1 Linux.
The javaversion is Java.Version = 1.4.2_11
The classpath does look like:
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> echo $CLASSPATH
/derby.jar:/derbytools.jar:/derbynet.jar:/derbyclient.jar:/derbyTesting.jar:/local/derby/tools/java/jakarta-oro-2.0.8.jar:/derbyLocale_de_DE.jar:/derbyLocale_es.jar:/derbyLocale_fr.jar:/derbyLocale_it.jar:/derbyLocale_ja_JP.jar:/derbyLocale_ko_KR.jar:/derbyLocale_pt_BR.jar:/derbyLocale_zh_CN.jar:/derbyLocale_zh_TW.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/classes12.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/classes12.zip:/oracle/oracle/product/10.2.0/db_1/jlib/orai18n.jar:/oracle/oracle/product/10.2.0/db_1/jdbc/lib/ojdbc14.jar:/home/Eisele/Oracle/ojdbc14.jar:/home/Eisele/FH-Weihenstephan/Winter_Semester_200809/Uebungen
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen>
The Program JDBCVersion.java which I copied out of the Oracle-Documentation looks like:
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
class JDBCVersion
public static void main (String args[]) throws SQLException
System.out.println("Java.Version = " + System.getProperty("java.version")) ;
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:scott/tiger@host:port:service");
Connection conn = ods.getConnection();
// Create Oracle DatabaseMetaData object
DatabaseMetaData meta = conn.getMetaData();
// gets driver info:
System.out.println("JDBC driver version is " + meta.getDriverVersion());
I get the following error
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> javac JDBCVersion.java
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen> java -cp ~/FH-Weihenstephan/Winter_Semester_200809/Uebungen/ JDBCVersion
Java.Version = 1.4.2_11
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/pool/OracleDataSource
at JDBCVersion.main(JDBCVersion.java:10)
Eisele@brezn:~/FH-Weihenstephan/Winter_Semester_200809/Uebungen>
Can anyone help me out here and tell me, what I did wrong ?
Thanks in advance !
RüdigerTwo thoughts.
The first is that 10.2.0.1 is unpatched. Why? It has been two years since its release and no one has applied 10.2.0.2, 10.2.0.3 or 10.2.0.4.
The second is that your question is not a database question but a Java question is you are more likely to get an answer that will help you if you post in a group where it is on-topic. -
Location of 'oracle.jdbc.OracleDriver'
Hi everyone,
I am starting out learning JDBC and am trying to compile and run this sample Java program:
package project1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import oracle.jdbc.OracleDriver;
public class jdbc_test1 {
* @param args
* @throws SQLException
public static void main (String[] args) throws SQLException {
try {
DriverManager.registerDriver(new OracleDriver());
catch (SQLException e) {
e.printStackTrace();
Runtime.getRuntime().exit(1);
When I 'make' the project, I get the error 'OracleDriver not found' on the 'import' line.
My environment:
Windows Vista
Oracle 10.2.0.3.0
JDeveloper 10.1.3.3 and 11.1.1
CLASSPATH: .;d:\App\Oracle\product\10.2.0\db_1\jdbc\lib\ojdbc14.jar;d:\App\Oracle\product\10.2.0\db_1\jlib\orai
18n.jar
I searched both jar files looking for OracelDriver, but found nothing. What am I missing?
Thanks.
rrI get the error 'OracleDriver not found' Note that this kind of driver to be imported is depreciated.....
http://forums.oracle.com/forums/ann.jspa?annID=201
As a substitution for this use....the following packages....
import java.sql.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
and make then the appropriate changes in your main() method... such as:
public static void main(String args[]) throws Exception
Connection con =null;
try
OracleDataSource ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:scott/tiger@//<host_name>:<listener_port>/<your_tns>");
con = ods.getConnection();
catch (Exception ex)
//System.out.println("Unable to connect..."+ex.printStackTrace());
System.out.println("Unable to connect..."+ex);
System.exit(-1);
}Greetings...
Sim -
Oracle.jdbc.oracledriver not found
Hi,
i have this code .. given below. I installed the oracle client version 8. but everytime i run this code i get the oracledriver not found message. I put the oracle jdbc drivers in the class path. but the code just refuses to compile.
Can anyone tell me what is wrong here. i have a funny feeling that the classpath is not set properly. let me know whats wrong here.
ps: i havent set the system DSN - coz i am getting stuck at the drivers itself.
It says the following .
AccessDB.java:26: Class oracle.jdbc.driver.OracleDriver not found.
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
i have the CLASSPATH=D:\oracle\ora81\jdbc\lib\classes111.zip;D:\oracle\ora81\jdbc\lib;D:\oracle\ora81\jdbc\lib\classes12.zip;D:\oracle\ora81\jdbc\lib\nls_charset11.zip
the code is as follows
//: AccessDB.java
import java.sql.*;
* Access the Database through JDBC
public class AccessDB {
private Connection con = null;
private Statement stmt = null;
private DatabaseMetaData meta = null;
private String dbURL;
private String dbUser;
private String dbPassword;
* Connects to JDBC driver
public void connect(String dbURL, String dbUser, String dbPassword){
try {
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Class.forName ("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection(dbURL,dbUser,dbPassword);
stmt = con.createStatement();
meta = con.getMetaData();
catch(Exception e){
System.out.println("connect: " + e);
System.exit(0);
* Disconnects from JDBC driver
public void disconnect(){
try {
if (stmt != null) stmt.close();
if (con != null) con.close();
catch(Exception e){
System.out.println("disconnect: " + e);
System.exit(0);
* Retrieves a Statement object
public Statement getStatement(){
return stmt;hi,
i have some problem in JSP oracle connectivity,
I'm running JRUN, PWS under WIN98.
the following is the code for Oracle connection from JSP
<%@ page import="java.sql.*" %>
<HTML>
<HEAD>
<title>Example JSP</title>
</HEAD>
<BODY>
<table width="50%" border=1>
<th>Table Name</th>
<th>Table Type</th>
<%
java.sql.Connection con;
java.sql.ResultSet rs;
java.sql.Statement sta;
Class.forName("oracle.jdbc.driver.OracleDriver");
con=java.sql.DriverManager.getConnection("jdbc:oracle:thin:@NTSERVER1:1521:orcl","DOHMS","TA");
sta=con.createStatement();
rs=sta.executeQuery("select * from USERS");
while(rs.next()) {
out.println("<tr><td>"+rs.getString(1)+"</td><td>"+rs.getString(2)+"</td></tr>");
%>
</table>
<BODY>
the following is the error:
Exception thrown on line '21' from page 'C:\\Program Files\\Allaire\\JRun\\servers\\default\\demo-app\\jsp\\dbtest.jsp'.
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver [oracle.jdbc.driver.OracleDriver]
at allaire.jrun.servlet.JRunServletLoader.loadClass(../servlet/JRunServletLoader.java:430)
at java.lang.ClassLoader.loadClass(ClassLoader.java:265)
at allaire.jrun.jsp.JSPClassLoader.loadClass(../jsp/JSPClassLoader.java:118)
at java.lang.ClassLoader.loadClass(ClassLoader.java:265)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:325)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:135)
at jrun__jsp__dbtest2ejspf._jspService(jrun__jsp__dbtest2ejspf.java:49)
at allaire.jrun.jsp.HttpJSPServlet.service(../jsp/HttpJSPServlet.java:39)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:228)
at allaire.jrun.jsp.JSPServlet.service(../jsp/JSPServlet.java:196)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1416)
at allaire.jrun.session.JRunSessionService.service(../session/JRunSessionService.java:1082)
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:1270)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:89)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1552)
at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1542)
at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:364)
at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:115)
at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)
--------------- -
JGeometry / oracle.jdbc.OracleDriver ClassCastException
Hi-
I can't seem to store my JGeometry (from the SDO API) back to the database. The code that causes the problem is this:
===== Sample Code ========
import oracle.jdbc.OracleConnection;
OracleConnection oc = (OracleConnection) st.getConnection();
STRUCT struct = JGeometry.store((JGeometry)value,oc);
==========================
That last line of code throws this error:
===== Exception ============
05/01/04 16:50:26 [ERROR] ResultForm - Could not save the ResultBean <java.lang.ClassCastException>java.lang.ClassCastException
at oracle.jdbc.driver.OracleConnection.unwrapCompletely(OracleConnection.java:5075)
at oracle.jdbc.driver.OracleConnection.physicalConnectionWithin(OracleConnection.java:5126)
at oracle.sql.TypeDescriptor.setPhysicalConnectionOf(TypeDescriptor.java:494)
at oracle.sql.TypeDescriptor.<init>(TypeDescriptor.java:147)
at oracle.sql.ArrayDescriptor.<init>(ArrayDescriptor.java:186)
at oracle.sql.ArrayDescriptor.createDescriptor(ArrayDescriptor.java:118)
at oracle.spatial.geometry.JGeometry.createDBDescriptors(JGeometry.java:1323)
at oracle.spatial.geometry.JGeometry.store(JGeometry.java:1257)
at gov.usgswim.wdnr.fishform.GeometryType.nullSafeSet(GeometryType.java:54)
=========================
It looks like the oracle.jdbc.driver.OracleConnection.unwrapCompletely method is assuming the connection to be something that it is not - but I'm stumped without the source code.
I've seen someone speculate that this is a classloader issue, but I'd have no idea how to resolve that within OC4J.
Here is my setup:
Running from JDev 9.0.5.2 using OC4J 9.0.5.
JDBC connections are provided via JNDI by specifying the datasource thru JDev. I've tried replacing the JDBC drivers that come with OC4J with the newer versions (that is, classes12.jar --> classes14.jar)
Database version is 10.1.0.3.0
I'm pretty much stuck until I can work this out, so any help would be appreciated.
Thanks in advance,
Eric EvermanHi LJ - Thanks for the reply.
I'm leaving out detail about the framework I'm working within. For instance, the full method that saves the JGeometry back to the db is part of a Hibernate UserType for which I can't change the method signiture - thus the PreparedStatement.getConnection(). The full method looks like this:
=========== Java Method =================
public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
STRUCT struct = null;
if (value != null) {
if (value instanceof JGeometry) {
JGeometry jg = (JGeometry)value;
System.out.println("Storing a Geom object to the db. Info:");
System.out.println(" Type: " + jg.getType());
System.out.println(" # of points: " + jg.getNumPoints());
System.out.println(" isPoint: " + jg.isPoint());
System.out.println(" X, Y: " + jg.getFirstPoint()[0] + ", " + jg.getFirstPoint()[1]);
//System.out.println(" elemInfo length: " + jg.getElemInfo().length); (throws error)
OracleConnection oc = (OracleConnection) st.getConnection();
struct = JGeometry.store(jg,oc);
} else {
throw new HibernateException("Cannot set GeometryType value to " + value.getClass().getName());
} //keep null value
st.setObject(index, struct);
==================================
==== Typical Output ==============
05/01/04 20:53:08 Storing a Geom object to the db. Info:
05/01/04 20:53:08 Type: 1
05/01/04 20:53:08 # of points: 1
05/01/04 20:53:08 isPoint: true
05/01/04 20:53:08 X, Y: 385343.3057, 562597.748
==================================
I've no reason to think that the connection I'd get from the prepared statement would be anything other then the connection returned from JNDI, but I'll try a simplified test to make sure.
My Geom is point data - would I expect JGeometry.getElemInfo() to return null in that case? Currently it does return null immediately after I load the JGeom from the database. -
Needing help in oracle.jdbc.OracleDriver
the problem is when i perform a select statement from a database link to another database in another machine the resultset returns empty, but when i am created the database in the same machine all goes fine.
i dont no where is the problem??????
is the problem in oracle or in oracle driver or i miss something else
plz help me.i dont no where is the problem??????
is the problem in oracle or in oracle driver or i miss
something elseYeah, the problem must be in Oracle. It couldn't be you or your code. That's perfect, of course.
Call Larry Ellison and demand that he fix that stinking pile of c-r-a-p code he's sold you. -
Hi,
I am writing a J2EE application which (in theory, at least)
connects to an Oracle 9i database.
I have written a simple Java test app utilising only the
java.sql package classes (e.g. Connection, ResultSet) to directly
connect to the database. As long as the classes12.zip is in the
CLASSPATH it works fine.
Now I have written an Enterprise application (SessionBean,
Remote and Home interface and Client) which I am attempting to
deploy via deploytool.
If I include just the client jar and EJB jar in the application
it deploys okay but when I run the application (using runclient)
it produces the following error:
java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
(It is nested within other error output but that is the core
issue).
However if I try to include the JAR libraries into the app
(classes12.jar and nls_charset.jar from $ORACLE_HOME/jdbc/lib),
then I get the following output from deploytool when I hit the
"deploy" (or "redeploy") button:
Deployment error: invalid entry compressed size
(expected 14411 but got 14580 bytes)
Can someone please tell me what is going on???
How can I deploy the J2EE application including the Oracle
JDBC Driver???
My only other option at the moment is to place all the function-
-ality in the client and not use the J2EE framework.
Any help is greatly appreciated.
Regards,
Ben New
Leftclick Software Development
[email protected]OK Ben,
I admit I'm a bit confused. Let me see if I understand where you're
coming from.
You have written a J2EE application that includes a session bean,
correct? If so, your session bean needs to be deployed to an EJB
container. What container are you using? The Oracle 9i database
has an embedded EJB container which (theoretically) you can use.
However, as far as I know, Oracle recommends you use OC4J as the
EJB container. So again I ask, what EJB container are you using?
If, as you say, you are new to EJB, then I think you should
immediately start working wiht OC4J as your EJB container.
Did you look at the tutorial link I gave in my previous post? It
explains -- step by step -- how to create, deploy and run a J2EE
application using OC4J as the EJB container. It also has links to
introductory material for people without little knowledge of J2EE
and EJB.
I have 9iAS Enterprise Edition and 8.1.7.1.0 database server (and
OC4J) installed on my SUN machine. I cannot find any of the
utilities you mention -- "j2eeadmin","runclient" or "deploytool".
What Oracle software have you installed? What are the versions?
What platform are you using?
A J2EE application (according to the specification from SUN)
consists of modules. A module can either be a client module or an
EJB module. A client module can either be a java application client
or a web-based client (servlet or JSP). A J2EE application usually
contains one client module and one EJB module. A J2EE application
needs to be deployed to a J2EE container.
Hopefully the J2EE picture is becoming clearer. I think you need
to read some introductory material regarding J2EE if you intend
to become proficient at it.
I feel that you are under the impression that a J2EE application
is a glorified JDBC application. It isn't (as far as I'm aware).
Good Luck,
Avi. -
Hi All,
Getting the above error when running the following export utility:
$ java oracle/apex/APEXExport
ABove error is thrown.
I have looked at most blogs suggested by ML.
Here are my env params:
echo $CLASSPATH
/u01/app/oracle/product/11.2.0/db_1/jdbc/lib/ojdbc5dms.jar
( No, i don't see any classes12.jar. The classes12.zip resides in oui folder. I tried that as well and it didnt work)
echo $JAVA_HOME
/usr/java/jdk1.7.0_02
So for the heck of it, I tried:
$ export CLASSPATH=.:${ORACLE_HOME}/jdbc/lib/classes12.zip
and lo, I am able to at least summon this:
$ java oracle/apex/APEXExport
Usage APEXExport -db -user -password -applicationid -workspaceid -instance -skipExportDate -expSavedReports -debug
-db: Database connect url in JDBC format
-user: Database username
-password : Database password
-applicationid : ID for application to be exported
-workspaceid : Workspace ID for which all applications to be exported
-instance : Export all applications
-skipExportDate : Exclude export date from application export files
-expSavedReports: Export all user saved intera
BUT: when invoking specific job, I get this:
java oracle/apex/APEXExport -db hostname:1521:SID -user apex_030200 -password welcome123 -instance
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
at oracle.apex.APEXExport.main(APEXExport.java:315)
any ideas?Hello,
I get a very similar error.
Windows 7 Ultimate SP1
Oracle XE 11.2
Apex 4.1
jdk 6u31-windows x64.exe (installed to C:\Program Files\Java\jdk1.6.0_31\.....)
User Variable CLASSPATH = .\; C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib\ojdbc5.jar
User Variable JAVA_HOME = C:\program files\java\jdk1.6.0_31\jre\bin
User Variable ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server
System Variable PATH = C:\oraclexe\app\oracle\product\11.2.0\server\bin;;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\11.0\DLLShared\;C:\Program Files (x86)\Pinnacle\Shared Files\;C:\Program Files (x86)\Pinnacle\Shared Files\Filter\;C:\Program Files (x86)\QuickTime\QTSystem\
At the C:\apex\utilities directory I give the command:
java oracle.apex.APEXExpress -db localhost:1521:XE -user SUSANNA -password skippy123 -expworkspace
I get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/apex/APEXExpress
Caused by: java.lang.ClassNotFoundException: oracle.apex.APEXExpress
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doProvileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: oracle.apex.APEXExpress. Program will exit. -
Oralce 10G2 JDBC Driver - Error Loading oracle.jdbc.driver.OracleDriver
When attemping to use the 10G2 jdbc driver the following NoClassDefFoundError is encountered:
Exception in thread "main" java.lang.NoClassDefFoundError: while resolving class: oracle.jdbc.driver.OracleDriver
<<No stacktrace available>>
Caused by: java.lang.ClassNotFoundException: oracle.security.pki.OracleWallet not found in [file:./, file:ojdbc1410g2.jar, file:/usr/share/java/libgcj-3.4.4.jar, file:./, core:/]
<<No stacktrace available>>
The error does not occur when reverting back to the 9 jdbc driver. Does anyone know what is causing this behavior?
Regards,
PaulPaul,
Actually, class "oracle.jdbc.OracleDriver" extends class "oracle.jdbc.driver.OracleDriver".
So check the JAR files in the list displayed by your error message and see if any of them contain the [missing] class, for example:
jar tvf ojdbc1410g2.jar oracle/jdbc/driver/OracleDriver.classGood Luck,
Avi.
Maybe you are looking for
-
Word document won't 'print' to PDF on proper paper size
I have a document in MS Word that's on a 5.5x8.5 page size. If I do a Save As, the resulting PDF uses the proper paper size, but it also shows color--which I don't want for this particular document. When I do Print and choose Adobe PDF, I can choose
-
Hi. I'm trying to use example from "Oracle JDev 10g Handbook". I'm using OracleXE. I have testing schema (named "GM"). That schema contains 3 tables. I have created Connection - connection is named "XE_GM" and it is working fine (connectiong, showing
-
I went to the "Account setup" screen, selected "mac.com account" then clicked on the "get an iChat account". I filled in the form and crated my account. I can go to myinfo.apple.com and log in with my mac.com address/pw. But when I type in that accou
-
I can't copy a song from my PC to itunes or to my ipod
For some reason I can't seem to copy files from my PC to iTunes or to my ipod. I've trid drag and drop, add song and add folder. None seem to work. Please help!!
-
FileVault can't copy disk image?
Hi Folks, I wanted to enable FileVault on my computer but it keeps failing when I try to initiate it. I get a message saying that it can't copy disk image. What can I do about that? I won't be back online until Friday so if you have any more question