First of all, I know there are a lot of answers about this and I already checked them all, but this is a bit more specific I think.
I am developing a REST web service using Jersey, but I have this little problem when connecting to the mysql database. I have added the connector dependency in the pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
And if I check the build options the relative jar is in the eclipse java build path, but I get the error anyway, unless I add
Class.forName("com.mysql.jdbc.Driver");
before creating the connection.
I tried creating a java project adding the connector driver manually in the java build path and it works, so I guess it is something strictly related to maven or tomcat. I am using java 7 and tomcat 7.