Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Common resultSet Function

 
naval kumar
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Problem When I am making Common Function Of ResultSet.Actully I want To Call This Function From Different Function To get The Result Set. Like


But Problem Is that If i Will Get The Result Set Its Shwoing Nothing Beacuse i Have Close the Connection Here of databsase and Result set.If if Will Close The Resultset and database connection From The Calling Function Then I got Some more Issue that I have to setAttribut of Resulset On servlet and Get This On JSp So I can not Close the resultset On servlet If i Do like It then How Can i Close the database Connection And Result set Connection.Otherwise Lot of Resultset and database Connection Will Open.
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kumar ,

Instead of returning the ResultSet object ( not advisable ) , it is always preferred to return a bean of values obtained from the result set. I would suggest that after you get the result set object ( rs ) , you set up an array list of objects and populate the array with the rows obtained in this result set and then return this List of objects instead of returning the ResultSet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic