Ank
Ank

Reputation: 6270

Connecting to MySQL from Java to WAMP / MAMP Pro

I am trying to connect from java to a MySQL database from an external computer on a machine hosting WAMP and other hosting MAMP Pro. The connection to WAMP is fine but on MAMP Pro, I get the following error.

              String userName = "user";
              String password = "pass";
              String url1="jdbc:mysql://<IP Address>:3306/dbname";
              Class.forName ("com.mysql.jdbc.Driver").newInstance ();
              conn1=DriverManager.getConnection (url1, userName, password);


The last packet sent successfully to the server was 0 milliseconds ago. 
The driver has not received any packets from the server.

I had changed the privellages in both the server by going to Privellages in PhpMyAdmin and chaning host to any host under Login Information. Worked for WAMP but didn't work for MAMP Pro.

Any suggestions?

Upvotes: 1

Views: 7678

Answers (1)

Ank
Ank

Reputation: 6270

I'm answering my own question but after some struggle I found the solution. Hopefully it will help people like me in future.

I opened MAMP Pro and on Server - General tab I clicked

File => Edit Template => MySql my.conf and changed 
line no 37 from 
bind-address=127.0.0.1 to bind-address = <my server's IP Address>

Upvotes: 3

Related Questions