In JDBC, how can you ensure that all resources are freed, even if an SQL exception occurs?

  • Close resources in the catch block
  • Implement a custom resource management mechanism
  • Resources are automatically freed in JDBC
  • Use the finally block to close resources
Using the finally block ensures that resources (like connections, statements, result sets) are closed, even if an SQL exception occurs, promoting proper resource management and avoiding leaks.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *