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

Gurwinder Singh
  • 35,652
  • 5
  • 39
  • 62
  • [JDBC ODBC bridge have been removed from Java 8](http://stackoverflow.com/questions/21955256/manipulating-an-access-database-from-java-without-odbc). Also, you tagged Oracle in your question. Are you trying to connect Oracle using JDBC ODBC drivers? – Gurwinder Singh Apr 01 '17 at 06:02

1 Answers1

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:

Community
  • 1
  • 1
Stephen C
  • 632,615
  • 86
  • 730
  • 1,096