title: MS ACCESS jdbc.odbc connection. data source name not found/No default driver specified?
body: <p>I'm trying to study for a basic SQL test at school but unfortunately I copied the class that we are supposed to use into a project on my pc and I am getting the following error: </p>
  
  <blockquote>
    <p>java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified</p>
  </blockquote>
  
  <pre><code>package Question1;
  
  // Your name, Q 1
  import java.sql.*;
  import java.io.*;
  import javax.swing.*;
  
  public class GreenWood
  {
   // Set up database connection
     private static final String DATABASE_FILE_NAME = "WoodDB.mdb";
     private static final String DRIVER = "jdbc:odbc:DRIVER=" +
     "{Microsoft Access Driver (*.mdb)};" +
     "DBQ=" + new File (DATABASE_FILE_NAME).getAbsolutePath ();
    static
    {
       try
       {
          Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
       }
           catch (ClassNotFoundException e)
          {
             System.out.println ("Class not found");
             e.printStackTrace ();
          }
    }
  
  
    private Connection dbcon;
    private BufferedReader keyb = new BufferedReader (new InputStreamReader (System.in));
  
     public GreenWood ()
    {
       System.out.println ("WoodDB Connection");
       try
       {
          dbcon = DriverManager.getConnection (DRIVER);
          Statement stmt = dbcon.createStatement ();
          System.out.println ("Connection successful\n");
  
          char choice = ' ';
          do
          {
  
           //Prints options for user input
  
             choice = keyb.readLine ().toUpperCase ().charAt (0);
             System.out.println (" ");
             switch (choice)
             {
               //calls query methods based on user input
  
             }
          }
          while (choice != 'X');
          dbcon.close ();
          System.out.println ("Done");
          Thread.sleep (1000);
          System.exit (0);
       } // try
           catch (Exception e)
          {
          // process exceptions here
             System.out.println ("Connection unsuccessful");
             e.printStackTrace ();
             System.out.println (e.toString ());
          }
    } // HoutSoorte constructor
  
    //Query Methods
    //Main creates new instance of GreenWood
  </code></pre>
  
  <p>my WoodDB database is located in the root project directory.</p>
  
  <p>I Have done some troubleshooting and I believe that the problem is the URL of the driver location;</p>
  
  <pre><code>dbcon = DriverManager.getConnection (DRIVER);
  </code></pre>
  
  <p>DRIVER being:</p>
  
  <pre><code>private static final String DRIVER = "jdbc:odbc:DRIVER=" +
     "{Microsoft Access Driver (*.mdb)};" +
     "DBQ=" + new File (DATABASE_FILE_NAME).getAbsolutePath ();
  </code></pre>
  
  <p>After about an hour of research I'm still just as confused as I was.
  If anyone can help this nub programmer(me) by explaining the problem in baby words and how I can fix it, it would be ever appreciated.  </p>