Forum Stats

  • 3,876,074 Users
  • 2,267,056 Discussions
  • 7,912,419 Comments

Discussions

ClassNotFoundException in sun.jdbc.odbc.JdbcOdbcDriver

2695041
2695041 Member Posts: 1
edited Jun 18, 2014 7:37AM in New To Java

Hi Experts,

  I am new to Java Programming..and trying to learn the nuances of the language from industry experts...

  As a beginner in JDBC programming, I am trying to establish a simple connection to the MS Access DB (2007) from my app...but all I am getting is Exceptions...ClassNotFoundException and SQLException (no suitable drivers)...??

I have my classpath variable set to the  JRE lib ...

Code::-

import java.sql.*;

import java.lang.Class.*;

class sample {

  String  url;

  Connection con;

   sample(){

       try{

                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

  url = "jdbc:odbc:;Driver={Microsoft Access Driver (*.accdb)}; DBQ=C:\\Program Files\\Java\\mandeep\\newdata.accdb";

  con = DriverManager.getConnection(url);

  System.out.println("connection established");

                 }

            catch(Exception e){

            System.out.println(e.getCause().getMessage());

             }

            }

 

          

   public static void main (String[] args) throws Exception {

  sample s = new sample();

              

               

  }

}

PLEASE HELP!!

Mandeep

Answers

  • Wrong forum!

    JDBC questions should be posted in the JDBC forum. Please mark this question ANSWERED and repost there.

    https://community.oracle.com/community/developer/english/java/database_connectivity/java_database_connectivity_(jdbc)

    Class not found generally means just that: there is NO such class anywhere on the classpath or in any of the jars in the classpath.

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge

    except that this is an internal class to the standard API...

    A class that's been marked as "don't use" for the last decade or so...

    It is there in Java7, don't have 8 installed here so can't check if it was at last removed.

    It might also not be there on non-Windows JVMs, as it makes no sense to have an ODBC-JDBC bridge driver on platforms on which ODBC does not exist.

    OP: switch to a real database, the bridge driver is unsupported, buggy, slow, and relies on 32 bit ODBC which itself is unsupported, deprecated, buggy, slow and may not even be included with 64 bit versions of Windows (and never is on other platforms).

  • except that this is an internal class to the standard API...

    I have no idea how that relates to what I said.

    Class not found generally means just that: there is NO such class anywhere on the classpath or in any of the jars in the classpath.

    That class is in the rt.jar file.

    That jar file is part of the JRE - not the JDK. If that jar file is not on the classpath you will get that exception.

  • jwenting
    jwenting Member Posts: 4,864 Gold Badge
    rp0428 wrote:
    
    except that this is an internal class to the standard API...
    I have no idea how that relates to what I said.
    
    

    It's not JDBC related, therefore has no place in the JDBC forum.

    rp0428 wrote:
    Class not found generally means just that: there is NO such class anywhere on the classpath or in any of the jars in the classpath.
    That class is in the rt.jar file.
    
    That jar file is part of the JRE - not the JDK. If that jar file is not on the classpath you will get that exception.
    

    If that jar file isn't on the classpath, there's something really weird going on, as it's implicitly on the classpath.

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy

    Its the OJDB-JDBC bridge. I am going to make an educated guess that the OP is using Java 8 - the driver has been removed from that release as JWenting suspects.

This discussion has been closed.