Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect desktop application with application server and Database

I have a design problem about how to connect Desktop Java application which needs to read and write from Database. Which one of the two approaches is better?

  1. Connect the Desktop Java application directly to the Database using JDBC driver over the network. This is very bad idea because if the security but it will be very easy to write SQL queries directly and execute them.

  2. Connect the Java Desktop application to Application server which will be connected to the Database. In this case how I'm going to do the SQL queries? I need some kind of a tunnel which will be used to transfer the queries and return the output. This is approach is very secure but the response time will be big.

Can you tell me are there any other solutions?

like image 878
Peter Penzov Avatar asked Jan 26 '26 13:01

Peter Penzov


1 Answers

The best option is to use EJB Server.

Create an EJB Inteface with all the crud methods (save,delete ,update etc).

Create an EJB Implementation on the server (Jboss/GlassFish) .

Once the server is up and running then just copy the Interface Jar file to your application(java Swing App) and using JNDI you can call all the crud operations.

~I hope that helps.

like image 52
Makky Avatar answered Jan 29 '26 02:01

Makky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!