Skip to Main Content

New to Java

ClassNotFoundException in sun.jdbc.odbc.JdbcOdbcDriver

2695041Jun 16 2014 — edited Jun 18 2014

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

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2014
Added on Jun 16 2014
5 comments
16,712 views