java – Client-server application and databases


Hello! I am writing a client-server application in Java. In the process, the question arose: how best to organize interaction with the database?
That is, for example, a client logs in and sends a username and password to the server. After successful completion of this operation, it will continue to interact with the server.
Is it worth putting the service working with the base into a separate thread, creating a queue of requests to it, or is it possible for each client to make a direct call to the class working with the base?


Let's start from the fact that such a question may have an answer for everyone, which is bad. Well, I will answer anyway)
There should not be direct access to the database, at least because of readability. The DAO layer must access the database, and the methods of the DAO layer must use the SERVICE layer and the user can already have direct access to them, in my case through the controller layer.

Scroll to Top