title: connecting to a database through JDBC
body: <p>I am trying to follow a tutorial in a book on connecting a program to a database with JDBC. I am confused on what the first block of code is doing in the class. whan i run the code i get an error saying that <code>java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:8889/book_store</code> </p>
  
  <p>and the code is throwing an exception in that first block inside the class. do i need to add some sort of dependency or library to the project?</p>
  
  <p>as you can tell this is my first attempt at using a db...</p>
  
  <pre><code>package com.apress.books.dao;
  
  import com.apress.books.model.Author;
  import com.apress.books.model.Book;
  import com.apress.books.model.Category;
  
  import java.sql.*;
  import java.util.ArrayList;
  import java.util.List;
  
  public class BookDAOImpl implements BookDAO {
  
  static {
      try {
          Class.forName("com.mysql.jdbc.Driver");
      } catch (ClassNotFoundException ex) {
      }
  }
  
  private Connection getConnection() throws SQLException {
      return DriverManager.getConnection("jdbc:mysql://localhost:8889/book_store",
              "root", "password");
  }
  
  private void closeConnection(Connection connection) {
      if (connection == null)
          return; try {
          connection.close();
      } catch (SQLException ex) {
      }
  }
  @Override
  public void insert(Book book) {
  
  }
  
  @Override
  public void update(Book book) {
  
  }
  
  @Override
  public void delete(Long bookId) {
  
  }
  }
  </code></pre>