Java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver [How to Solve]

Java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver error reporting solution

Error report description problem description cause analysis solution operation results

Error reporting description

java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver reports an error


Problem description

when learning the contents of Java database, because the old version of teaching materials are used, and the Java version has been updated and some functions have been deleted, an error message prompted by java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver appears when reading the database: 

try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        } catch (ClassNotFoundException e) {
            System.out.println(e);
        }

Error message: java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcdriver


Cause analysis

since JDK1.8, the JDBC ODBC bridge has been deleted, so the ODBC driver cannot be used </ font>


Solution

 

    1. Step 1: install the old version of JDK. I install the download link of version 1.7 here: just click the next step for the jdk1.7 installation step. Step 2: change the Java environment

 

    1. friends using eclipse can refer to this blog:

 

    1. java.lang.classnotfoundexception: sun.jdbc.odbc.jdbcodbcodbcdriver solution 2.1 I use the integrated development environment of idea, The method is as follows:

 

    1. in file – project structure

    1. in project settings, select the JDK version downloaded for you by project SDK (here is 1.7)

 

    1. and click apply to run


Operation results

run smoothly ^ ^

Read More: