Exception on loading JDBC-ODBC driver

≯℡__Kan透↙ 提交于 2019-11-30 09:51:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!