• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java Swing and ojdbc

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why i get this when i click on save button which i have created in my application " Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver " ?                                                        
Untitled2.png
[Thumbnail for Untitled2.png]
this is the error i got
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you executing this?
What is the classpath defined either in the jar file's manifest, or on the command line?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error means that you do not have the Oracle JDBC driver JAR file in your classpath when you run the program.

Make sure that the Oracle JDBC driver JAR is in the classpath.
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks @Drave Tolls and @Jasper de Jong  i have mentioned path of ojdbc14.jar in my batch file to run this code . when i tried to execute the code for only jdbc-odbc connection it runs perfectly but when i include it in my project it giving me this error. i am not getting what exactly wrong.
this is my batch file code :
set path=C:\jdk\bin;
set classpath=C:\apache-tomcat-9.0.0.M18\lib\ojdbc14.jar;
javac *.java
java DataBasehandler
pause
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that batch file work for compiling?
The classpath is missing '.', ie the current directory (presumably containing the DataBasehandler.java file).
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks @Dave Tolls, yes i changed name class DataBasehandler by MainFrame because my MainFrame contains main Method and when i complie using *.java it complies successfully without any error but same error occurs when i hit save Button button used in my project to insert record into database.  
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the jar file isn't needed for compiling, so are you sure that it is actually in that location?

As an aside, that's quite an old ojdbc jar file.  Are you sure it's the correct one to use with the version of Oracle you have?
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks @Dave Tolls, yes it's the correct ojdbc jar file, i have used it before for simple jdbc-odbc connection it works fine and yes am sure it is actully in that location.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without your machine it's going to be hard to help, really.
The cause of that error is that it can't find the class.
That is almost always because the jar file was not on the classpath when the app was launched.
Occasionally it's because the class isn't in that jar file (sometimes classes are moved between packages in different versions).

That's it.
There's not much more that can be said.

Can you run the code by simply doing:
java -cp C:\apache-tomcat-9.0.0.M18\lib\ojdbc14.jar;. MainFrame
from the command line?
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thankyou @Dave Tolls, yea i did it as you said now it is giving me this error
"java.sql.SQLException: Io exception: Invalid number format for port number".
 
Mayuresh Chavan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done .... Thank you so much @Dave Tolls now it is working fine i tried different port numbers i.e "1521/XE" thank you so much for your Help !  
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic