0

i am new in database want to run first database progrom with oracle but getting error java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

i wrote following code

     // DDL(Data Definition Language)

   // Two commands
  // 1. create
 // 2. insert

// To execute this command used method create

// create command

 import java.sql.*;
  import java.io.*;
 class create
 {
  public static void main(String[] args)
    {
        try
      {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            System.out.println("Drivers loaded");
      Connection con=DriverManager.getConnection("jdbc:odbc:new","system","cse");
        System.out.println("Connection established");
        Statement st=con.createStatement();
        st.execute("Create table student(sno varchar(20),sname varchar(20),sadd varchar(20))");
        System.out.println("Table created");
        st.close();
        con.close();
    }
    catch(Exception e)
    {
        System.out.println(e);
    }
}

}

error snapshot

1

1 Answer 1

2

If you are trying to connect to a Oracle database (e.g. Oracle 10g) then you should not be using the JDBC / ODBC bridge. You should be using the appropriate Oracle drivers, and a JDBC URL of the appropriate type. This Q&A covers this topic:

There is more information on the Oracle website.

The JDBC / ODBC bridge are for connecting to a database that "speaks" ODBC; e.g. Microsoft Access or Excel. If this is what you really require, then you need a 3rd-party JDBC / ODBC bridge driver. Java 8 and later no longer include this driver, as described in this Q&A:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.