When a connection is closed in a connection pool, what actually happens to that connection?
- It is immediately returned to the pool
- It is marked as unavailable
- It is permanently deleted
- It is physically closed
When a connection is closed in a connection pool, it is not physically closed but rather returned to the pool, making it available for reuse. This enhances efficiency by minimizing the need for new connections.
Which component in a Java EE application is responsible for managing connection pooling?
- Connection Pool
- Enterprise JavaBeans (EJB)
- JDBC Driver
- Servlet Container
Connection pooling is typically managed by a dedicated component known as the connection pool, which handles the creation, management, and recycling of database connections in a Java EE application.
How would a filter log request information without altering the request itself?
- Use a separate logging library
- Use a wrapper around the ServletResponse
- Use response.getWriter().write()
- Use response.log() method
To log request information without altering the response, a filter can use a wrapper around the ServletResponse. This allows capturing the response data without modifying it.
What is the primary advantage of using a PreparedStatement in JDBC?
- PreparedStatements are faster than Statement objects.
- PreparedStatements are used for executing stored procedures.
- PreparedStatements help prevent SQL injection attacks.
- PreparedStatements require a connection pool.
PreparedStatements are precompiled SQL statements that are faster than Statement objects, providing better performance in JDBC operations.
During peak usage, a web application's response time degrades significantly. Which connection pool setting should be investigated?
- Connection Timeout
- Max Connections Per Partition
- Min Pool Size
- Partition Count
To address degraded response time during peak usage, investigate the Max Connections Per Partition setting, which controls the maximum number of connections allowed in each partition.
_________ in connection pools helps to identify and replace connections that are no longer viable.
- Expiration
- Monitoring
- Replacement
- Validation
Validation in connection pools helps to identify and replace connections that are no longer viable or have become stale.
When no connections are available in the pool, the request is put into a __________ until a connection becomes available.
- buffer
- hold
- queue
- stack
When no connections are available, the request is put into a queue until a connection becomes available in the pool.
To ensure efficient use of database connections, pools use a technique called _________.
- Connection Caching
- Connection Optimization
- Connection Pooling
- Connection Recycling
To ensure efficient use of database connections, pools use a technique called Connection Pooling.
The process of retrieving a connection from the pool, using it, and then returning it is known as _________.
- Connection Fetching
- Connection Recycling
- Connection Recycling
- Connection Releasing
The process of retrieving a connection from the pool, using it, and then returning it is known as Connection Fetching.
In connection pooling, the pool size is defined by the _________ and _________ parameters.
- initialConnections, maxConnections
- initialSize, maxSize
- minConnections, maxConnections
- minSize, maxSize
In connection pooling, the pool size is defined by the initialSize and maxSize parameters.
How can stale or broken database connections in the pool be handled effectively?
- By ignoring them and letting the database manage it.
- By logging the issue and continuing to use the connection.
- By notifying the database administrator.
- By removing them from the pool and establishing new connections.
Stale or broken database connections in the pool can be handled effectively by removing them from the pool and establishing new connections. This helps maintain a reliable and efficient connection pool for the servlet container.
What is the impact of setting a very high or very low size for the connection pool?
- Both high and low sizes have a negative impact on performance.
- High size can lead to resource wastage, while low size may cause performance issues.
- High size improves performance, but low size reduces resource usage.
- Setting size doesn't affect performance.
Setting a very high size for the connection pool can lead to resource wastage, while a very low size may cause performance issues. It's essential to find an optimal size to balance performance and resource usage effectively.