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.

_________ 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.

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.

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.

What method is used to execute a stored procedure using a CallableStatement?

  • callProcedure()
  • execute()
  • executeProcedure()
  • executeQuery()
The execute() method is used to execute a stored procedure using a CallableStatement.

How can you retrieve the output of a stored procedure using CallableStatement?

  • getOutput()
  • getOutputParameterValue()
  • getProcedureOutput()
  • getResultSet()
You can retrieve the output of a stored procedure using getOutputParameterValue() method in CallableStatement, which returns the value of a designated OUT parameter after the stored procedure execution.

What is the impact on performance when using PreparedStatement for repeated database operations?

  • Decreased performance due to compilation
  • Improved security with parameterized queries
  • Increased performance due to query caching
  • No impact on performance
Using PreparedStatement can lead to increased performance as the query is precompiled and cached, reducing database load and improving execution speed.

How do you handle transaction management when using PreparedStatement and CallableStatement?

  • Explicitly commit transactions using commit()
  • Rollback transactions using rollback()
  • Transactions are automatically managed
  • Use Connection.setAutoCommit(false)
To handle transactions with PreparedStatement and CallableStatement, set auto-commit to false using Connection.setAutoCommit(false) and then explicitly commit or rollback transactions using commit() and rollback() methods, respectively.

To set a date in a PreparedStatement, the method _________ is used.

  • setDate()
  • setDateValue()
  • setTime()
  • setTimestamp()
The setDate() method is used to set a date in a PreparedStatement when working with JDBC.

When using a CallableStatement, the method _________ is used to register an OUT parameter.

  • outParameter()
  • registerOutParameter()
  • registerOutput()
  • setOutParameter()
When using a CallableStatement in JDBC, the registerOutParameter() method is used to register an OUT parameter.