java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver doesn't work anymore in java. How to fix this?

前端 未结 2 1816
执念已碎
执念已碎 2021-01-24 01:31

It worked two days ago. Now it doesn\'t. I\'m 100% sure the coding is correct. This is the way I used to connect the database. Couldn\'t find an answer yet to my problem. Please

相关标签:
2条回答
  • 2021-01-24 01:52

    Based on the comments, your system is now running on the Java 8 JRE. The ODBC Bridge has been removed from this, and all future versions. You need to find a native JDBC driver for the database you want to connect to, and put that on your classpath.

    java -classpath "[/path/to/your/driver.jar];." [yourclassname]
    

    Alternatively, you could explicitly use the JDK 7 runtime, but I'd recommend against this. You've uncovered a compatibility problem, and it's better to solve it than to try to work around it.

    0 讨论(0)
  • 2021-01-24 01:59

    Please add your jar to the class path like below.

    java -cp .;C:\Program Files\MySQL\mysql-connector-java-5.1.15\mysql-connector-java-5.1.15.jar MysqlConnect

    Note:Please replace msql connector with your jar file as per requirement.

    0 讨论(0)
提交回复
热议问题