0

I have a simple web application built on Servlet and simple DAO classes to handle database (MySQL) operations.

My servlet may receive multiple requests at the same time. How will the database handle multiple requests?

Suppose I have an "item" database table. Multiple requests may update or delete from the "item" table at the same time.

Is it required to use Transactions and lock the table explicitly during update and delete operations in the DAO class, or will concurrency be handled by the database automatically?

MFH
  • 357
  • 3
  • 17
  • I recommend reading about [ACID (`en.wikipedia.org`)](https://en.wikipedia.org/wiki/ACID) and [isolation levels (`en.wikipedia.org`)](https://en.wikipedia.org/wiki/Isolation_(database_systems)). --- As I see it, the question is not really about java, but DBMS and most probably off-topic for StackOverflow. – Turing85 Jan 20 '23 at 16:28
  • This question will most likely get closed as opinion based, but in general, reads don't need transactions. Transactions are needed for writing (insert, update, delete) operations and transactions are normally handled by the Service Layer. I would look into application layers (UI, Services, DAO/Repositories) and go from there. Good luck. – hooknc Jan 20 '23 at 16:31
  • 1
    @hooknc everything is transactional. If we do not create an explicit transaction, an implicit one is created. – Turing85 Jan 20 '23 at 16:40
  • What database technology are you using? A flavor of SQL? – TylerH Jan 20 '23 at 17:14
  • @Turing85 thank you for the correction. I have to admit that some of my transaction knowledge is a bit shaky, but I could see there always being a transaction. – hooknc Jan 20 '23 at 17:50
  • @TylerH, I am using MySQL. – MFH Jan 21 '23 at 15:06
  • Note that it is important to avoid opinion-based language like "should I"--opinion-based questions are off-topic on Stack Overflow. – TylerH Jan 23 '23 at 15:31

0 Answers0