title: SQLException: no suitable driver found for jdbc:mysql between two maven projects
body: <p>I've 2 maven projects in my Eclipse (v4.7.0) workspace.</p>
  
  <p>The first project contains some utility stuffs and holds the connection to my MySQL database through JDBC driver. </p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.example&lt;/groupId&gt;
    &lt;artifactId&gt;dbtools&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
    &lt;packaging&gt;jar&lt;/packaging&gt;
    &lt;name&gt;DBTools&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;!-- JDBC for MySQL --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;mysql&lt;/groupId&gt;
          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
          &lt;version&gt;6.0.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;commons-beanutils&lt;/groupId&gt;
          &lt;artifactId&gt;commons-beanutils&lt;/artifactId&gt;
          &lt;version&gt;1.9.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;persistence-api&lt;/artifactId&gt;
          &lt;version&gt;1.0.2&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>This first project is built as a jar and it is included in the second project (that contains the main application) as a maven dependency as shown in the pom.xml below:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
   &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
   &lt;groupId&gt;com.example&lt;/groupId&gt;
   &lt;artifactId&gt;mainapp&lt;/artifactId&gt;
   &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
   &lt;packaging&gt;war&lt;/packaging&gt;
   &lt;name&gt;MainApp&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;jersey2.version&gt;2.25.1&lt;/jersey2.version&gt;
      &lt;jaxrs.version&gt;2.0.1&lt;/jaxrs.version&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
  &lt;/properties&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-clean-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.6.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;filesets&gt;
                      &lt;fileset&gt;
                          &lt;directory&gt;C:/apps/tomcat/webapps/mainapp&lt;/directory&gt;
                          &lt;includes&gt;
                              &lt;include&gt;**&lt;/include&gt;
                          &lt;/includes&gt;
                          &lt;followSymlinks&gt;false&lt;/followSymlinks&gt;
                      &lt;/fileset&gt;
                  &lt;/filesets&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;copy-appCtx&lt;/id&gt;
                      &lt;phase&gt;generate-resources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;copy-resources&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;outputDirectory&gt;C:/apps/tomcat/webapps/&lt;/outputDirectory&gt;
                          &lt;overwrite&gt;true&lt;/overwrite&gt;
                          &lt;resources&gt;
                              &lt;resource&gt;
                                  &lt;directory&gt;../mainapp/target&lt;/directory&gt;
                                  &lt;includes&gt;
                                      &lt;include&gt;mainapp-0.0.1-SNAPSHOT.war&lt;/include&gt;
                                  &lt;/includes&gt;
                              &lt;/resource&gt;
                          &lt;/resources&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencies&gt;
      &lt;!-- JAX-RS --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.ws.rs&lt;/groupId&gt;
          &lt;artifactId&gt;javax.ws.rs-api&lt;/artifactId&gt;
          &lt;version&gt;${jaxrs.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- Jersey 2.25.1 --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
          &lt;version&gt;${jersey2.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
          &lt;version&gt;${jersey2.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;
          &lt;version&gt;${jersey2.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- Local DBTool --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.example&lt;/groupId&gt;
          &lt;artifactId&gt;dbtools&lt;/artifactId&gt;
          &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>The 2nd project that is the main application is deployed as a war file.
  When I start the Tomcat (with 2nd app's war) I got a <strong>SQLException</strong> at runtime:</p>
  
  <pre><code>java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mydb?autoReconnect=true&amp;useSSL=false
  at java.sql.DriverManager.getConnection(DriverManager.java:689)
  </code></pre>
  
  <p>I've read several question here in StackOverflow about this exception but I still haven't found a working solution :(</p>
  
  <p>Inside the lib folder of my Tomcat installation folder I've placed the <strong>mysql-connector-java-6.0.6.jar</strong>.</p>
  
  <p>I've also noticed that in the JAR file of the first project (opening it as an archive) there isn't the JDBC connector inside. Is it normal?</p>
  
  <p>Inside the first project, I make the connection this way:</p>
  
  <pre><code>conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/torre?autoReconnect=true&amp;useSSL=false", "dbuser", "dbpass");
  </code></pre>
  
  <p>conn has type java.sql.Connection.</p>
  
  <p>I've also tried to put:</p>
  
  <pre><code>Class.forName("com.mysql.jdbc.Driver");
  </code></pre>
  
  <p>before che "conn = ..." line but I got the same result :(</p>
  
  <p>I'm using Tomcat 8.5 and JDK 1.8.</p>
  
  <p>Any ideas how I can get rid of this problem?
  Am I missing something in the Maven or Eclipse build configuration?</p>
  
  <p>Thanks in advance for your help! :)</p>