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.
1 Answer
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.
ipconfigthat will tell you what local IP address the computer is using, if it's running on linux you can useifconfig. You can then connect to that host using the local IPV4 displayed. You should also edit your question tag, it's not relevant to java. You'll require port-forwarding to achieve the connection and also, remote login may be required on the MySQL config.