title: intelij idea adding mysql connector to project library
body: <p>I am trying to connect a mysql database to my java project, but I'm getting the error: <code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver</code></p>
  
  <p>As seen in the image, I added mysql-connector-java-5.1.48.jar to my project, but it still gives me the error.</p>
  
  <pre><code>public static Connection getConnection(){
          try {
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              return DriverManager.getConnection(url, username, password);
          } catch (SQLException ex) {
              throw new RuntimeException("Error connecting to the database", ex);
          } catch (IllegalAccessException | ClassNotFoundException | InstantiationException e) {
              e.printStackTrace();
          }
          return null;}
  </code></pre>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
      at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
      at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
      at java.base/java.lang.Class.forName0(Native Method)
      at java.base/java.lang.Class.forName(Class.java:291)
      at DatabaseAccess.DbConnection.getConnection(DbConnection.java:17)
      at DatabaseAccess.DbConnection.main(DbConnection.java:27)
  </code></pre>