I'm trying to make a java application that connects to a database that is not located on my pc. I'm not sure how to do this. If I create my own database with MySQL, where do i need to store the database in order to acces it from other computers. I want to know what do I need in order to do this. I checked the internet and saw a lot of examples using jdbc and connecting to a url with localhost or something like this. Thank you!
1 Answer
Local: the server address will be 'localhost' or '127.0.0.1' You can install mysql on your computer and connect to it with the computer's ip (generally 192.168.1.??). You can install LAMP or MAMP to have mysql working easily on your network ('put online' option).
Internet: the server adresse is given by your host, replace the 'localhost' or '127.0.0.1' address on the jdbc parameters.
5 Comments
Alex Chihaia
And do i need a server for that?I don't really understand how does MySQL works. Could you explain the process for me please?I mean, i want to create the database from a pc and then i want to have acces to it from any pc at any given time.
user207421
@AlexChihaia MySQL is a server.
Tokazio
The principle of a 'server' is that a 'machine' was running all the time then you can connect to it at any given time, we called this a 'server' (eg a server computer). Then on this machine you can install any program that can handles connection, like 'apache' for HTTP, or 'mysql' for database, these are servers applications (on server computer).
Tokazio
In your case you need a computer that run everyday with mysql installed on it. But to do this at home, you need a static ip address to connect to it from external. it's not the simplest way. Else you can find a host provider that handle all this for you.
Alex Chihaia
@Tokazio Managed to solve the problem. Thanks for your help!
localhost, you have to put the remote host name or ip address, That's about it.3306for connect (if correctly configured). JDBC on any other computer connects to port3306.localhost::3306with{your-host-name}:3306Only you know what you hostname is.