Mohamed E-Zumry
Mohamed E-Zumry

Reputation: 1

How to design a client server architecture for Swing clients and a database?

I have written an application in java Swing that runs in 8 machines under a Local Area Network and accesses a mysql db. The program is running fine. But, now my client has decided to set up a new branch at a distant location which should be connected to the existing branch. How can I modify/extend my application to handle that situation. client wants to use it in normal internet connection.any ideas will be great help.

Upvotes: 0

Views: 1054

Answers (2)

Jonas
Jonas

Reputation: 128807

You should not connect directly from the Swing clients to the database. It's better if you implement a service to communicate with the database, and the Swing application communicate with the service.

The easiest thing may be to set up a web server, and communicate with JSON using an Apache HTTP Client in your Swing application. That is what I'm using.

In summary you need three parts:

  • Swing client application, that has a built in HTTP Client. Communicates with a web server.
  • A web server that responds to requests from client applications and is connected to the database via JDBC
  • The database itself.

As Ajay suggests, the deployment will be easier if you use Java Web Start.

Upvotes: 5

Ajay George
Ajay George

Reputation: 11875

Use Java Web Start. The client would download the jnlp file and open the GUI using that

Also have a clear separation between your view and model. Your client will talk to a service which can give you the data from the DB.

Upvotes: 1

Related Questions