title: Java not connecting to MS Access database using Eclipse
body: <p>Can anyone help me? I've already tried to solve this for one hour and I'm still confused.
  Below is my code and i get this error when compiling.</p>
  
  <p>Output msg::</p>
  
  <pre><code>DriverLoaded
  Could Not Connect to Databasejava.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
      at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
      at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at java.sql.DriverManager.getConnection(Unknown Source)
      at DBConnect.&lt;init&gt;(DBConnect.java:11)
      at DBConnect.main(DBConnect.java:21)
  </code></pre>
  
  <p>Code::</p>
  
  <pre><code>import java.sql.*;
  
  public class DBConnect {
  
      public DBConnect() {    
          try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              System.out.println("DriverLoaded");
              String url = "jdbc:odbc:; DRIVER = Microsoft Access Driver (*.mdb, *.accdb); DBQ = DB.accdb";
              Connection con = DriverManager.getConnection(url);
              System.out.println("Connection Established Successfully");
          } catch(Exception e) {
              e.printStackTrace();
              System.out.println("Could Not Connect to Database");
          }
      }
  
      public static void main (String args[]) {       
          DBConnect dbcon = new DBConnect();  
      }
  }
  </code></pre>