CPSC 343 Database Theory and Practice Fall 2024

JDBC Local Quick Start

JDBC is an API for connecting to a database. You need a connector for your particular database in order to be able to use it.

This document is intended to describe the local environment for working with JDBC in CPSC 343. Refer to the Java Tutorial for information on using JDBC.


Contents


Installation

If you are working on your own computer, you will need to download the JDBC connector for MySQL.


Setup

Once you have the JDBC connector, you'll need to add it to the build path of every Java project that connects to a database. In Eclipse:

You will need to do this each time you create a new project.

Note: If you have the JDBC connector correctly configured but running the program results in the error something went wrong: No suitable driver found for jdbc:mysql, try adding the following line before the DriverManager.getConnection(url) step:

  // load and register the JDBC driver
  Class.forName("com.mysql.cj.jdbc.Driver");