Make sure you have the MySQL jdbc connector. And then, try this:
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/mysql?user=root&password=edureka");
}
catch (Exception ex) {
ex.printStackTrace();
}
And replace the username and password used for the database.