0

I'm trying to build portfolio and I have problem with using online mysql database. I have code like this:

public class DBManager {
    public static String _host = "sql8.freesqldatabase.com";
    public static String _port = "3306";
    public static String _user = "************";
    public static String _pass = "**************";
    public static String _db = "**********";

    private static Connection connection;

    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        if (connection == null) {
            Class.forName("com.mysql.jdbc.Driver");
            String url = "jdbc:mysql://" + _host + ":" + _port + "/" + _db + "";
            connection = DriverManager.getConnection(url , _user, _pass);
        }
        return connection;
    }
  }

Some database works in workbench, before that I was working on a local database. Now I have an error like this:

Access denied for user 'sql8167592'@'host-79.173.28.129.tesatnet.pl' (using password: YES)

2 Answers 2

1

You need to execute following line on your MySQL server.

ALTER USER 'your username'@'your ip' IDENTIFIED BY 'your password';

EDIT: Remove your MySQL server ip, username and password from your question!!!

Sign up to request clarification or add additional context in comments.

Comments

1

Ensure the user exists in the database and the credentials are ok, if it is saying access denied, it means that the url is correct and there is a mysql server in that address

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.