Excesses and database connection

1

I have a code that does a query in a database. If an exception occurs for timeout for example during query execution, the closing code of the connection and consequent return of the connection to the pool will not occur, should I use a try-finally to even pass through the closing code of the connection? / p>     

asked by anonymous 03.05.2018 / 14:58

1 answer

1
  

Should I use a try-finally to even pass through the close code of the connection?

Yes.

If you're using Java 7 or higher, you can use the try-with-resources .

    
04.05.2018 / 16:38