MySQL in Java Desktop applications for various stores [closed]

0

Hello, if I make a Java Desktop application with MySQL database, which will be delivered to several establishments to use, how is the database? Do you have any suggestions? The application, I can get it to be installed easily, but what about the database part? Will each location have to install MySQL and also create the necessary tables?

    
asked by anonymous 28.01.2017 / 19:48

1 answer

2

It depends what you want. If each establishment must have its database independent, then the database is installed on a physical server inside the establishment and the terminals connect to it by means of an IP of type 192.168.XX . Another possibility is that each establishment chooses to host somewhere outside (such as some cloud computing server), but then it needs to connect to the internet and not just a local network.

If you want all of them to use the same MySQL database, you are hosting it somewhere (possibly some cloud computing service) and then everyone connects to it via the public IP or hostname that you make available.

Anyway, it all boils down to the connection string: jdbc:mysql://<host-do-servidor>:3306/<nome-do-seu-database> . In place of <host-do-servidor> you put the IP of the server or the hostname of it. You can leave the IP or hostname fixed in the source code or read it from a configuration file.

As for creating tables, you would create them as part of the MySQL installation process. If you are going to install MySQL on each site then you would create the tables. If you are going to make a single place where everyone accesses, you only need to create the tables once.

In addition, you should also keep an eye on security. If you have several different locations sending instructions of type INSERT , UPDATE , DELETE and SELECT to a single centralized place, it's very easy for someone to arrange to send instructions like these out of your program. Simply have the username, password and connection string that can be retrieved from within the program easily. This is why we often use server-side applications that access the database exclusively and client applications should only communicate through the application on the server: This ensures the encapsulation of the database of data.

    
28.01.2017 / 20:00