This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Instead of that if i close the connection first in the finally blocks what will happen... Is the statment and resultset object take handle by JVM?
Adeel Ansari wrote:When you close connection, the statement and resultset both, attached with that particular connection will get closed automatically.
In a properly implemented driver. Which unfortunately one cannot rely on having.
Joined: Aug 15, 2004
I believe, there are very few, if there are, applications which don't use pooling for connections. So, in case you are employing a pooling mechanism, then there is no closing for connections on your end, therefore you must close statements and resultsets. Of course you need to set the connection back to the pool.
I believe, closing a statement should automatically close the resultset. I hope there are no exceptions in this regards. Please let me know. Further, you must free all Blob, Clob etc. objects, because they remain valid, even when you close the resultset.