# Create a Database to query First, set up a MySQL database. For the purposes of this demonstration I set up a simple database called **bluecoat** with one table: **student**. The table has four columns of type varchar: Forename, Surname, Gender and Form. # Add mysql-connector JAR You will need to download the mysql-connector [JAR](https://en.wikipedia.org/wiki/JAR_(file_format)) and add it to your classpath. # Jar File * <https://dev.mysql.com/downloads/connector/j/> * Choose Platform independent and download ZIP archive ![[mysql connector.png]] ## To add or import jar files in your Eclipse IDE, follow the steps given below. 1. Make sure you have unzipped the archive above. 2. Right click on your project. 3. Select Build Path. 4. Click on Configure Build Path. 5. Click on Libraries and select Add External JARs. 6. Select the jar file from the required folder 7. Click and Apply and Ok. ![[Build Path.png]] # Java Class Set up the following class Don't forget to add `requires java.sql;` to the module ```java import java.sql.Connection; import java.sql.DriverManager; public class Main { public static void main(String[] args) { try { //Load mysql jdbc Driver      Class.forName("com.mysql.cj.jdbc.Driver").newInstance(); // Connect to Database      Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bluecoat", "root", ""); } catch (Exception ex) {       System.err.println(ex); } } } ```