Selçuklu Ebrar
Selçuklu Ebrar

Reputation: 2279

Unable to connect to MySQL after deploying my application

I have installed MySQL to my local computer. I can access MySQL from my Java Application which is running on my computer.

My connection string is private String url = "jdbc:mysql://localhost:3306/mydatabase" which allows me to connect successfully. But when I deploy my application to other computers on my LAN and try to connect to my MySQL databases from the other computers I can't access my database.

Upvotes: 1

Views: 461

Answers (1)

Robert H
Robert H

Reputation: 11730

As others have mentioned in the comments, you issue is your connection string: private String url = "jdbc:mysql://localhost:3306/mydatabase"

In order for you to be able to connect to your database from other machines on your LAN you will need to change localhost to your IP address. For example:

private String url = "jdbc:mysql://192.168.0.10:3306/mydatabase"

Providing that the other machines can see 192.168.0.10 they will be able to connect (with the right credentials of course!)

Upvotes: 3

Related Questions