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?
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.
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With