I'm having issues connecting to an external IP address using JDBC. When I execute the following code, I get this error No suitable driver found for jdbc:mysql://52.206.157.109:3306/U054Jk
Code:
package util;
import java.sql.*;
public class db {
private static String server = "52.206.157.109";
private static String dbName = "U054Jk";
private static String userName = "secret";
private static String password = "secret";
private static Connection getCon() throws SQLException {
String host = "jdbc:mysql://" + server + ":3306/" + dbName;
Connection conn = DriverManager.getConnection(
host,
userName,
password
);
return conn;
}
public static ResultSet ExecQuery(String query) throws SQLException {
//Get the connection
Connection conn = getCon();
//Create the statement
Statement stmt = conn.createStatement();
//Execute the statement
ResultSet rs = stmt.executeQuery(query);
//Return ResultSet
return rs;
}
}
I can connect with my SQL client just fine using the credentials but can't quite figure out the JDBC string that I need for the URL. Thank you for your help.