Reputation: 745
I know how to connect to computer's mysql database using java, but I don't have idea what IP i will use when there are so many computer on same network. Lets say there are three computer at my home using same Wi-Router but one of them has the database installed. Also How to connect a computer's database that are internal to an access point having same public IP.
Upvotes: 0
Views: 68
Reputation: 821
Connect to an external or internar DB Server it's irrelevent for Java. You will define a URL like this <IP>:<port>/<DB_Name>
in both cases.
If your java server is inside your local net you should use the private IP of the DB server.
If your java server is in an external net you should use the Public IP and the port you've defined in your NAT. Yoy will need to configure the port forwanding, that means: Tell your NAT that all the incomings request for port X should be redirected to the DB server. This is all router's configuration, not java code.
Upvotes: 1