It looks like the program is missing the MySQL connector JAR. In order to connect the JDBC driver is required thing.
We need to ensure that JDBC API can find the driver associated with the URL "jdbc:mysql://"
In case of using any development IDE (Netbeans, Eclipse) the simplest way is to download the JAR file (mysql-connector-java-bin.jar) from MySQL website to the root of the project folder.
That means we are adding the JDBC driver in the classpath. Now we just need to load the driver inside our program manually like this-
Class.forName("com.mysql.jdbc.Driver");
So the program should be replaced like this-
import java.sql.Connection;
import java.sql.Drivermanager;
import java.sql.SQLException;
public class dbConnection {
public static void main(String[] args) {
//creating a connection object
Connection myConnection = null;
try {
String connectionUrl = "jdbc:mysql://localhost:3306/mysql";
String user = "default";
String pass = "admin";
Class.forName("com.mysql.jdbc.Driver");
myConnection = DriverManager.getConnection(connectionUrl, user, pass);
if( myConnection == null) {
System.out.printf("Successfully Connected");
}
}
catch (SQLException error) {
System.out.printf("error occured!");
error.printStackTrace();
}
}
}
Problem now should be resolved and don't forget to debug by logging program output.