How to access a remote mysql database using java

前端 未结 3 1684
不思量自难忘°
不思量自难忘° 2021-01-07 09:22

I have already developed a JAVA SWING Application. I want to install this application in several computers which all have access to

相关标签:
3条回答
  • 2021-01-07 09:36
    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.

    0 讨论(0)
  • 2021-01-07 09:44

    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.

    0 讨论(0)
  • 2021-01-07 09:52

    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!!

    0 讨论(0)
提交回复
热议问题