1

I have already developed a JAVA SWING Application. I want to install this application in several computers which all have access to internet . So where should I place my MYSQL Database ? All these computers should have the ability to access the same database via the internet.

3 Answers 3

3

It's not very common to allow access to a database directly over the internet for security (authentication authorization, encryption) and performance reasons. In most cases, you would create a web-based server application which can perform database operations, enforcing business, domain, and security rules. The client application makes calls over the internet (using REST calls, AJAX calls, or something proprietary), and gets the results back from the server.

In your case, since your client software is Java, you may want to research Java Servlets and run something lightweight like Tomcat as a serer.

Please see this page and this page for an explanation of client-server relationships.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I know creating a website would serve this purpose, but I've already created the SWING application.
You misunderstood me. I'm talking about a server-side application your Swing application would call to get its data. I included the links at the end to explain how and why.
2
  1. Put your database in host that is accessable by Internet.
  2. For each of the external ip addresses of each of the Applicaton host create a user on mysql.

    GRANT ALL PRIVILEGES TO database.* to `user1`@`APPLICATION_HOST_IP` identified by 'PASSWORD';
    

Now user1 will have access from APPLICATION_HOST_IP IP.

1 Comment

I used a VPN Client named "Hamachi" to get a static IP .
1

Well the possibility is limitless.. You can place it on every computer that is accessible by the others. As long as you can acces the database via network it does not really matter where it is. But if the Computers with your client Swing are all connected in LAN, than store the DB on the computer with best Performance. As a tip use the IP, and port dynamicaly from text or entry, so u do not recompile every time u change the IP. Chiers!!

5 Comments

Thats more like it :) Now my database is stored on one computer which is connected to a LAN. But there are some more computers which are not connected to this LAN because they are located somewhere else. How to setup the IP address if these computers wanted to connect to the database via the Internet ? Thanks
If you really want to go this route, you can have remote users VPN into the LAN (see en.wikipedia.org/wiki/Virtual_private_network). I still recommend having a server component between the application and the database, though.
i will agree with dj_segfault.... VPN with broker architecture... But the easyest solution for your problem is simple, just pick a hosting that offeres database possibility, and put it on that server. I will assume that you do not use complicated transactions so it would not be a hudge problem.. but i will strongy suggest to give each swing appication different user, and turn the autocommit off, and work with transactions.
Ok I'll try that and one more question ! How to use the IP and port dynamicaly from text or entry ?
before making the connection with DriverManager.getConnection(IP:PORT) you need the IP and port, you can save them in a properties file with ip = XXX.XXX.XXX.XXX port = XXXXX and read the properties with getResource .... so whenever u need to set a new IP you do not need to recompile just change the properties file.... If you find this helpful please check my answer as usefull, give me a point for it :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.