title: Connect Java to a MySQL database
body: <p>How do you connect to a MySQL database in Java?</p>
  
  <p>When I try, I get </p>
  
  <pre><code>java.sql.SQLException: No suitable driver found for jdbc:mysql://database/table
      at java.sql.DriverManager.getConnection(DriverManager.java:689)
      at java.sql.DriverManager.getConnection(DriverManager.java:247)
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver
  </code></pre>