java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

后端 未结 3 346
终归单人心
终归单人心 2021-01-11 09:29

I am getting this error when compiling my java program

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Then I knew that I should ad

相关标签:
3条回答
  • 2021-01-11 09:56
    1. Open Netbeans IDE
    2. Right-click your Project.
    3. Select Properties.
    4. On the left-hand side click Libraries.
    5. Under "Compile" tab - click Add Jar/Folder button.
    6. Select Downloaded "mysql-connector-java-5.1.25-bin.jar" file (Download Connector/J from dev.mysql.com)
    7. Click OK
    8. Run Again... Its work.

    Thanks...

    0 讨论(0)
  • 2021-01-11 09:59

    You have to put the full path to the jarfile in the classpath (including the filename):

    .;C:\j2sdk1.4.2_16\jre\lib;
    C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar
    

    As Hippo said, you have to restart cmd after changing that. If it doesn't work, launch your program like this:

    java -cp ".;C:\j2sdk1.4.2_16\jre\lib;
    C:\Program Files\mysql-connector-java-3.1.144\mysql-connector-java-3.1.14-bin.jar"
    my.class.Name
    
    0 讨论(0)
  • 2021-01-11 10:01

    You just need to copy the mysql-connector-java-5.1.39-bin file in the Libraries of the project folder. Everything will work fine.

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