0
votes

I am trying to connect MS Access with Java Below is the error message

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Code-

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");      
    String database = "jdbc:odbc:DRIVER={Microsoft Access Driver (*.mdb,*.accdb)};DSN=C:\\ST\\BillingTrackerDB.mdb";
   Connection conn=DriverManager.getConnection(database, "", ""); 
2
What do you understand by the exception? Data source name not found - Braj
Where is the data-source-name defined in the database url? - Braj

2 Answers

1
votes
DRIVER={Microsoft Access Driver (*.mdb,*.accdb)}

is an invalid ODBC driver name for Access; it is missing a space. The correct name is

DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}
1
votes

What version of Java are you using? In Java 8, I was unable to use the JDBC-ODBC bridge as it has been removed in JDK 8. What I have found to use in place of the JDBC-ODBC bridge for connecting to Access Databases is a pure Java solution called UCanAccess. It has done everything I needed, so far.