After installation of the mysql-connector-java-8.0.16.jar from the SQL database, despite my best efforts to get my code to work, I am left with an error of denied access for a user. This is peculiar because the same user credentials work on my site, so the user in question has the right permissions to access the database. What could be wrong. Am I using the wrong imports.
The imports in question:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
The code in question is:
package real;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class myConnection
{
public int returnOperation()
{
try
{
String host = "jdbc:mysql://website.com/database";
String username = "user";
String password = "password";
Connection con = DriverManager.getConnection(host, username, password);
}
catch(SQLException e)
{
System.out.println("There is an error with the SQL database: " + e.getMessage());
}
return 0;
}
}
The error I keep receiving is:
There is an error with the SQL database: Access denied for user 'USER'@'IP ADDRESS' (using password: YES)
GRANT ALL PRIVILEGESwith@'%'for your user should allow that user to connect from any IP.