Home >Java >javaTutorial >Why Am I Getting a java.lang.ClassNotFoundException When Connecting to an MS Access Database?
Exception: java.lang.ClassNotFoundException when accessing MS Access database
This exception occurs when the Java Virtual Machine (JVM) cannot find the class for the specified driver class name. In this case, the exception is thrown when the code attempts to load the JDBC-ODBC Bridge driver ("sun.jdbc.odbc.JdbcOdbcDriver") using Class.forName().
For Java 7:
In Java 7, the JDBC-ODBC Bridge is still included, but its use is discouraged. It is recommended to use a third-party JDBC driver for MS Access, such as UCanAccess. To resolve the exception, remove the Class.forName() statement.
For Java 8 and above:
The JDBC-ODBC Bridge has been removed from Java 8 and above. You must use a third-party JDBC driver to connect to MS Access, such as UCanAccess. Refer to the documentation of the chosen driver for detailed instructions.
Additional Information:
The following link provides more information on accessing MS Access databases without ODBC using UCanAccess:
The above is the detailed content of Why Am I Getting a java.lang.ClassNotFoundException When Connecting to an MS Access Database?. For more information, please follow other related articles on the PHP Chinese website!