What are best practices for closing or caching sql connections?
I see things saying to always close it in finally block.
Though I also see things talking about caching them for future use.
How expensive is it to open new connections for each task?
I just started to work on a java data warehousing app someone else programmed. (and I don't have DB experience) It is a single threaded app that loads files into the DB, and does some aggregation and analysis. We have had some issues with deadlocks, which I wouldn't think should be a problem in a single threaded app. I see exceptions are swallowed and not logged all over the class that handles the DB connections, so I am hoping adding logging to those should provide some insight.
But I am hoping for some guidance on best practices for dealing with DB connections in the meantime.