In a highly concurrent web application, how would you design a servlet to handle database connections securely and efficiently?
- Open a new database connection for each request.
- Store database connections as static variables.
- Use a connection pool to manage database connections.
- Use synchronized methods for database operations.
Using a connection pool is a best practice in highly concurrent applications as it efficiently manages and shares database connections, reducing the overhead of opening and closing connections for each request.
Loading...
Related Quiz
- Which load balancing algorithm distributes requests based on the server with the least connections?
- In HTTP servlets, the _________ method is used to send error responses back to the client.
- An e-commerce website uses auto-scaling but faces downtime during sudden traffic spikes. What might be missing in their scaling strategy?
- How should a system handle a situation where a transaction is interrupted due to a system failure?
- How would a servlet handle a situation where both GET and POST requests need to be processed, but different actions are required for each?