Kevin Lin
Kevin Lin

Reputation: 71

Connecting to mySQL netbeans project from different computer and internet

I have been trying to find a solution on how to connect different computers working on the same project in netbeans (group project). So far I my windows desktop which is where the mySQL database is located (has the table with the information). And I have my mac laptop. If they are connected to the same internet I can access the database on my mac from netbeans just fine, but once I switch the internet connection on my mac to my phone hotspot, because I wanted to see if it would still work if they are not on the same internet connection. It does not work no connection is made the program just keeps running with no error. I have to force close the running application. This is the code I have for the connection to mySQL in net beans.

Connection conn=DriverManager.getConnection("jdbc:mysql://10.0.0.2:3306/logindb","root","password");

Thanks for the help!

Upvotes: 0

Views: 521

Answers (2)

user9695085
user9695085

Reputation: 11

I am not sure that I understand what you are trying to do.

One of the first things to do is to verify that you are giving your database processing program the correct URL. I have seen many examples on Oracle that have their sample programs connect from your computer to their database over the internet.Their database has a stable URL. Your database probably does not have a stable URL.

I think your problem is very much like the problem experienced when somebody has a remote security camera in one part of the city, and they want it to send video when required to their home computer. The big problem comes because your home computer gets a different numerical URL every time you boot up your computer and do something that makes it try to reach an internet site. Your computer negotiates with a remote computer to secure for you a temporary numerical URL. (There wouldn't be enough URLs if every computer had to have its own unique address in firmware.

Owners of remote cameras have to contract with one of several companies that provide a URL to you that, when sent out, actually goes to the aforesaid company which then assigned a numerical connection for the duration of your use of the computer and remote camera. So the camera connects to your home computer by using this alias. The company software in the middle takes care of the housekeeping.

You can learn more precisely how to do all of this by checking out the websites of various security camera producers.

Upvotes: 0

minus
minus

Reputation: 2786

The most probable reason is that you are not on the local network anymore, so you can't reach the server, to check if is so try to ping your DB server a see if it succeeds.

Upvotes: 1

Related Questions