Jump to content
Pegasus

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

Recommended Posts

I made a project with Intellij which is not osrs related.

The project use database.

The project works when I run it in Intellij.

However, the runnable JAR (.jar) compiled by IntelliJ shows this error when I run it.

I already added mysql-connector-java-5.1.38-bin.jar to artifact,

and IntelliJ generated mysql-connector-java-5.1.38-bin.jar and the program jar when I click rebuild artifact.

I don't use maven.

 

Could anyone tell me how to solve it step by step?

Edited by Pegasus
Link to comment
Share on other sites

5 minutes ago, Hi G00gle said:

https://stackoverflow.com/questions/23771129/cant-test-connection-to-mysql-using-intellij

 

Are you able to get a connection?

 

A solution might be in there, thought I'd put it in here.

The project works when I run it in intellij.

However, when my pc have low memory or I just don't want to turn on intellij,

I will just want to double click the .jar file, but it shows java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Link to comment
Share on other sites

where do you download this latest version of mysql-connector-java-8.0.12.jar file?

https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.12/

How to delete mention?

 

Not work after I use the mysql-connector-java-8.0.12.jar  too.

Could you tell me how do you do it step by step?:cate:

@Lordsthan

Edited by Pegasus
Link to comment
Share on other sites

7 hours ago, Pegasus said:

where do you download this latest version of mysql-connector-java-8.0.12.jar file?

https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.12/

How to delete mention?

 

Not work after I use the mysql-connector-java-8.0.12.jar  too.

Could you tell me how do you do it step by step?:cate:

@Lordsthan

Sure, pm'd.

  • Like 1
Link to comment
Share on other sites

As the name suggests classNotFoundException in Java occurs when JVM (Java Virtual Machine) tries to load a particular class and doesn't found the requested class in the classpath you specified. When building the project, java throws ClassNotFoundException exception because a file (the com.mysql.jdbc.Driver class) from the java mysql connectivity library is not found. The solution is adding the library to the project, and java will find the com.mysql.jdbc.Driver

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...