0

I want to connect my database to msaccess 2007 using java, but I hear that the jdbc bridge is removed from java 8.

Please guide me that where is the problem in the following code.

 import java.sql.*;  
 public class UserLogin
 {
     public static void main(String[] args)
     {
        try
        {    
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        // C:\\databaseFileName.accdb" - location of your database 
          String url = "JDBC:ODBC:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=" +     
        "C:\\Users\\Shakir\\Documents\\NetBeansProjects\\UserLogin\\me.accdb";
        // specify url, username, pasword - make sure these are valid 
        Connection conn = DriverManager.getConnection(url);

        System.out.println("Connection Succesfull");
         } 
         catch (Exception e) 
         {
        System.err.println("Got an exception! ");
        System.err.println(e.getMessage());

          }
      }
  }
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
Shakir Ali
  • 55
  • 3
  • 4
  • 11
  • What error are you getting? Questions seeking debugging help ("**why isn't this code working?**") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it **in the question itself**. Questions without **a clear problem statement** are not useful to other readers. See [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – DavidPostill Oct 14 '14 at 11:01
  • http://stackoverflow.com/questions/22984438/java-lang-classnotfoundexception-sun-jdbc-odbc-jdbcodbcdriver-exception-occurin – Karthikeyan Vaithilingam Oct 14 '14 at 12:05

2 Answers2

0

ODBC Data Source in your Control Panel Settings and add new database with source.

user3065326
  • 39
  • 1
  • 6
0

I hear that the jdbc bridge is removed from java 8.

Please guide me that where is the problem in the following code

The problem is precisely that the JDBC-ODBC Bridge has been removed from Java 8, so your code is trying to use a feature that is simply not available. Consider this approach instead:

Manipulating an Access database from Java without ODBC

Community
  • 1
  • 1
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342