Malwinder Singh
Malwinder Singh

Reputation: 7050

Exception on loading JDBC-ODBC driver

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

Upvotes: 1

Views: 4798

Answers (2)

LeoTorres
LeoTorres

Reputation: 142

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

Upvotes: 0

Petter
Petter

Reputation: 4165

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.

Upvotes: 2

Related Questions