How to handle multiple concurrent database requests/updates when using JDBC with servlets?
All the dbms provide the facility of locks whenever the data is being modified. There can be two scenarios: • Multiple database updates on different rows, if you are using servlets the servlets will open multiple connections for different users. In this case there is no need to do additional programming. • If database updates are on the same row then the rows are locked automatically by the dbms, hence we have to send requests to the dbms repeatatively until the lock is released by dbms. This issue is dealt with in the JDBC documentation; look up “Transactions” and “auto-commit”. It can get pretty confusing.
All the dbms provide the facility of locks whenever the data is being modified. There can be two scenarios: 1. Multiple database updates on different rows, if you are using servlets the servlets will open multiple connections for different users. In this case there is no need to do additional programming. 2. If database updates are on the same row then the rows are locked automatically by the dbms, hence we have to send requests to the dbms repeatatively until the lock is released by dbms. This issue is dealt with in the JDBC documentation; look up “Transactions” and “auto-commit”. It can get pretty confusing.
Related Questions
- Relational persistence: Most Java database programmers rely on the proven JDBC API. Why does SAP promote the newer standard, SQLJ?
- Can I enable requests to a JDBC connection pool for a database connection to wait until a connection is available?
- How to handle multiple concurrent database requests/updates when using JDBC with servlets?