Reputation: 1
i tried to test connect mysql by maven in IDEA, however it occurs "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" all the time, my code is like that in maven:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
in java:
Connection connection = null;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch (ClassNotFoundException e){
e.printStackTrace();
System.err.println("mysql class not found");
}
i've tried many methods and the mysql connector certainly in my .m2 folder, but it raises a 'java.lang.ClassNotFoundException: com.mysql.jdbc.Driver' exception all the time, it's really disappointing, can u help me out?
Upvotes: 0
Views: 513
Reputation: 620
The Problem could be with one of these below:
Lastly do a File -> Invalidate Cache & Restart your IDEA
Upvotes: 4