user1560820
user1560820

Reputation: 65

package oracle.jdbc.driver does not exist

Error in the following code ![error occured][1]

import java.sql.*;

public class DBConnect{
public static void main(String a[]) throws SQLException{
    // *package oracle.jdbc.driver does not exist*
    Driver d=new oracle.jdbc.driver.OracleDriver();
    DriverManager.registerDriver(d);
    System.out.println("Driver is registered");
    }
}

Upvotes: 5

Views: 58125

Answers (4)

Gulfam Suleman
Gulfam Suleman

Reputation: 71

You need to do following steps if you are using intellij

  1. Download jdbc7 or any version
  2. Add this jar on following path File>>Project Structure>>Libraries>> Image 1
  3. Click on Modules and add jar there too if you still face issue then you must see following problem Image 2
  4. Now click on problems>>fix>>add to dependency as given below Image 3 Hope this will fix your issue

Upvotes: 1

Sid
Sid

Reputation: 1

First run the program in netbeans and add Ojdbc14.jar file into the library of the program and then it will surely execute.

After executing in NetBeans, click Clean & Build Project.... This will create a jar file and then path like java -jar "C:\Users\s\Documents\NetBeansProjects\jdbcTest_course\dist\jdbcTest_course.jar" will be provided.

Enter this into a command prompt (cmd) and it will run.

Upvotes: -3

someone
someone

Reputation: 6572

You have to add ocjdbc jar in to your class path and try it like this.

if your jar file and java source is in same location. Use a command prompt and changed directory to that location. and execute following

 javac -classpath ocjdbc14.jar DBConnect.java

and see.

import java.sql.*;
import oracle.jdbc.driver.OracleDriver;

public class DBConnect{
 public static void main(String a[]) {
   try{
    Driver d=new OracleDriver();
    DriverManager.registerDriver(d);
    System.out.println("Driver is registered");
  }catch(SQLException e){
     System.out.println("Error occured "+e.getMessage());
     }
}
 }

Upvotes: 6

vikiiii
vikiiii

Reputation: 9456

You need to Add an oracle driver jar to the project build path,

Download Ojdbc14.jar file and put it in your classpath.

Upvotes: 3

Related Questions