简体   繁体   中英

JDBC-ODBC Connection

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, "", ""); 
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)}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM