0

I was working on a plugin that saves data inside of the database, but I got an exception:

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

I know that this means that the driver is not found, but I don't know how to install it. I'm using a Debian VPS, and I was wondering how to install it. Thanks in advance!

Gersom Rink
  • 53
  • 2
  • 9
  • 1
    You don't "install" it. You download the JAR (from the MySQL download site) and added to the JVM's classpath. – Stephen C Feb 10 '21 at 14:41
  • @StephenCI've tried it using [this anwser](https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project) but it didn't work, I still get the same error. – Gersom Rink Feb 11 '21 at 07:32
  • So are you using Maven? Nothing in your question says you are. Also, the driver needs to be on the runtime classpath, not the build time classpath. I'm afraid you haven't provided enough information in your question to allow us to give you specific help. – Stephen C Feb 11 '21 at 07:35

1 Answers1

1

If you use maven you can just add this to your pom.xml:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.23</version>
    <scope>compile</scope>
</dependency>
MCTzOCK
  • 44
  • 4