The following is the class I'm going to use for the main part of this tutorial. It's just the Quick Start code broken down into methods.
```java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBase {
private static Connection con;
DBase() {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
System.err.println(ex);
}
}
public static void makeConnection() {
try {
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bluecoat", "root", "");
} catch (SQLException ex) {
System.err.println(ex);
}
}
}
```
Check the connection by calling the makeConnection() method as follows. If everything is okay the program will simply terminate. If an exception is thrown, check your port number, username and password.
```java
public class DBase2016 {
public static void main(String[] args) {
DBase.makeConnection();
}
}
```