Where to close java PreparedStatements and ResultSets?

In Java 7, you should not close them explicitly, but use automatic resource management to ensure that resources are closed and exceptions are handled appropriately. Exception handling works like this: Exception in try | Exception in close | Result —————–+——————–+—————————————- No | No | Continue normally No | Yes | Throw the close() exception Yes … Read more

Understanding the meaning of the term and the concept – RAII (Resource Acquisition is Initialization)

So why isn’t that called “using the stack to trigger cleanup” (UTSTTC:)? RAII is telling you what to do: Acquire your resource in a constructor! I would add: one resource, one constructor. UTSTTC is just one application of that, RAII is much more. Resource Management sucks. Here, resource is anything that needs cleanup after use. … Read more