This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

statement and resultset closing

 
shashank beerla
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this right way to do it ?

 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12021
25
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shashank beerla wrote:is this right way to do it ?

Do what?
 
shashank beerla
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
closing the resultset and statement
 
shashank beerla
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as you can see i am using single statement for multiple queries
 
Paul Clapham
Sheriff
Pie
Posts: 20185
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pretty good attempt. The only problem is, the close() method can also throw an SQLException. At least it's declared that way. And yes, you're catching that exception. However if that exception were actually thrown, let's say at line 54 for example, then the PoolManager.returnConnection line would not be executed. So you aren't dealing with it adequately, if you want to be 100% bullet-proof. Even if line 54 threw an exception, you would want to carry on with the rest of the code in the finally-block.

And by the way setting a method's local variable to null is usually pointless, and when you do it immediately before leaving the method, it's always pointless.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic