title: Cannot get JDBC driver to work in tomcat jsp
body: <p>I try to make a simple example connection to a mysql database in jsp running on tomcat.</p>
  
  <p>Running the code below I get the response: No suitable driver found for jdbc:mysql://localhost/TestingDB</p>
  
  <pre><code>&lt;HTML&gt;
      &lt;HEAD&gt;&lt;TITLE&gt;Testing mysql&lt;/TITLE&gt;&lt;/HEAD&gt;
  &lt;BODY&gt;
  
  &lt;%@ page import = "java.sql.*"%&gt;
  
  &lt;%  
          String url = "jdbc:mysql://localhost/TestingDB";
  
          String user = "mysql";
          String password = "pwd";
  
      try {
          Connection con = DriverManager.getConnection(url, user, password);
          out.println("Success");
          Statement st = null;
          ResultSet rs = null;
          st = con.createStatement();
          rs = st.executeQuery("SELECT * FROM TestTable");
          while(rs.next()){ 
              out.println(rs.getString("String1"));
          }
  
      } catch (Exception e) {
          out.println(e.getMessage());
              e.printStackTrace();
          }
  %&gt;
  
  &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>I have put the mysql-connector-java-5.1.xx-bin.jar in the CATALINA_HOME/lib directory and when it did not work I tried to put it in the {appname}/WEB-INF/lib directory.</p>
  
  <p>I have restarted tomcat between each try using <em>services</em> <em>tomcat</em> <em>restart</em>.</p>
  
  <p>There should not be any problems accessing the database as it works fine using (pretty much) the same code in a standalone java class. </p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.Statement;
  import java.sql.ResultSet;
  
  class JDBCTest {
  
      private static final String url = "jdbc:mysql://localhost/TestingDB?useSSL=false";
  
      private static final String user = "mysql";     
      private static final String password = "pwd";
  
      public static void main(String args[]) {
              try {
              Connection con = DriverManager.getConnection(url, user, password);
              System.out.println("Success");
              Statement st = null;
              ResultSet rs = null;
              st = con.createStatement();
              rs = st.executeQuery("SELECT * FROM TestTable");
              while(rs.next()){ 
                    System.out.println(rs.getString("String1"));
              }
  
          } catch (Exception e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>I'm really running out of ideas. All help is welcome!</p>