问题
I am getting java.lang.ClassNotFoundException
on loading sun.jdbc.odbc.JdbcOdbcDriver
using Class.forName()
.
I am using MySQL as Data Source and I have added Data Source Name in ODBC Data Source Administrator (on Windows 8).
Here is the code:
class Connect {
check() {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
Output:
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
回答1:
Are you using Java 8? The class is no longer present there (more info). You could install Java 7 if you need to use it.
回答2:
This happened to me once, and what i did was importing the mysql jdbc library that came with the product when i downloaded it, after that i used the driver as it is explained in the page:
http://dev.mysql.com/doc/connector-j/en/connector-j-usagenotes-connect-drivermanager.html
hope this could help you
来源:https://stackoverflow.com/questions/25892923/exception-on-loading-jdbc-odbc-driver