Connecting to the MySQL Database Error in Java

advertisements

I have a java code and I am connecting to the mysql database with the following connection string.

 String userName = "admin";
 String password = "pass";
 String url = "jdbc:mysql://<my IP>/dbase"; //not localhost
 Class.forName ("com.mysql.jdbc.Driver").newInstance ();
 conn = DriverManager.getConnection (url, userName, password);

When I make a JAR (Runnable JAR through eclipse), and take it to another machine in the same network I get an error

Access denied for user 'admin'@'<another machine IP' (using password: YES) //not localhost

The IP magically changed to another machine IP when I take the JAR to another machine. admin user has all privileges possible.

Whats wrong? Please help !!


The IP address listed in the error message is the IP address of the machine your program is running on. It's telling you that you're not allowed to connect to MySQL from that IP address as root

You will need to talk to the person who configures/administers your MySQL database. More than likely this is an intentional security measure.