I am trying to connect to a MySQL Database using the mysql-connector-jar, which gets imported via maven. I have the dependency in the POM file as follows:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
And I initialize my connection with the code below:
String dbUrl = "jdbc:mysql:host";
String dbClass = "com.mysql.jdbc.Driver";
String query = "update aem_assets set path = (?), assetid = (?), filename = (?), cadid = (?) where id = (?)";
try {
Class.forName(dbClass).newInstance();
However, I keep getting java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found
. I am trying to avoid manually adding the jar to the build path since my company uses maven for builds and we want this tool to be run from multiple instances without having to add jars.
I have also tried it without the newInstance()
method.
I am referencing this article for implementation: https://dimitrisli.wordpress.com/2010/08/06/jdbc-mysql-maven-working-example/
Edit: I have added the JAR file to the module dependency.
However it is STILL giving me the error. Am I missing something?