File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

calling getStatement().close() on a ResultSet

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need some advice on this.
I have recently inherited a web application with unbelievably bad design(rather without any design at all ) . One of the problems is JSP's calling methods which open up a connection, create a statement, and then, believe it or not, return the result set to the JSP. The original programmer merrily forgot about closing the statement.
Now, of course, the best approach would be to factor away all JDBC code into java beans etc., but there are constraints on time and resources available.
One possible solution I am considering is - In each JSP page, after it is finished with the result-set, call
resultSet.close() and resultSet.getStatement().close().
One thing to note here is that the original connection used to create the statement would have been returned to the pool, and possibly new Statement objects created from it. Ugly as it is, but do you think this would work? Anything that I am overlooking here!
thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sonny,
There was a thread in this forum a little while ago about problems with resultSet.getStatement().close(). It seems that the getStatement() call does not always return a valid statement.
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jeanne.
Yeah, now that you mention it, I kinda remember that...and there was also a link to a discussion about it on a Sun forum. I'll look it up.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic