facebook

ClassNotFoundException: oracle.jdbc.driver.OracleDriver

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #246777 Reply

    I am getting the following error when i try to run my java class on the console of eclipse IDE. How would you set the class path for the oracle driver in eclipse and what do I have to set it too and what will be the name of the classpath variable:

    Loading JDBC Driver -> oracle.jdbc.driver.OracleDriver
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    Creating Statement…
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at testing.DDLExample.<init>(DDLExample.java:64)
    at testing.DDLExample.main(DDLExample.java:300)
    java.lang.NullPointerException
    at testing.DDLExample.performDDL(DDLExample.java:97)
    at testing.DDLExample.main(DDLExample.java:301)
    Exception in thread “main”

    Following is my Class:

    public class DDLExample {

    final static String driverClass = “oracle.jdbc.driver.OracleDriver”;
    final static String connectionURL = “jdbc:oracle:thin:@localhost:1521:CUSTDB”;
    final static String userID = “system”;
    final static String userPassword = “manager”;
    Connection con = null;

    /**
    * Construct a DDLExample object. This constructor will create an Oracle
    * database connection.
    */
    public DDLExample() {

    try {

    System.out.print(” Loading JDBC Driver -> ” + driverClass + “\n”);
    Class.forName(driverClass).newInstance(); 😈

    #246778 Reply

    Haris Peco
    Member

    JohnyBravo2004 ,

    You have to download oracle jdbc driver (otn.oracle.com) and add ojdbc14.jar (thin driver) in project classpath.
    I suppose that you use simple project, but if you use MyEclipse profile you have to add jar in ‘configure driver’

    best

    #246780 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev.

    #246781 Reply

    Riyad Kalla
    Member

    snpe is correct, you would need to download the Oracle driver and add it to your project’s Java Build Path under Libraries. Then running it from within Eclipse will pickup that classpath.

    #282336 Reply

    I added used added the Oracle driver to the “DB Browser”. How to I get my JSP to recognize the new DB connection? Do I still need to add the driver to my project’s Java Build Path also?

    #282350 Reply

    Riyad Kalla
    Member

    sonia,
    The DB Explorer is a tool inside the IDE to be used by you, it is completely disconnected from any project or webapp you might be using. If you need a JDBC connection inside your JSP page to your data source, you’ll need to make sure your JDBC driver is in the proper location for your web app and configure it yourself.

    If you decide you want to use some of the reverse-engineering features in MyEclipse though, MyEclipse will setup all the data related stuff for you in your project using either Hibernate, JPA or EJB 3. There are a slew of docs covering all our persistence technology support here if you are interested in that:
    http://www.myeclipseide.com/module-htmlpages-display-pid-7.html#jpt

    #282903 Reply

    RonNYC
    Member

    This message has not been recovered.

    #282980 Reply

    Riyad Kalla
    Member

    This message has not been recovered.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: ClassNotFoundException: oracle.jdbc.driver.OracleDriver

You must be logged in to post in the forum log in