This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Common resultSet Function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Common resultSet Function" Watch "Common resultSet Function" New topic
Author

Common resultSet Function

naval kumar
Ranch Hand

Joined: Jul 08, 2012
Posts: 37
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

Joined: Aug 11, 2011
Posts: 440

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.

Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Common resultSet Function
 
Similar Threads
java.sql.SQLException: Server configuration denies access to data source
Update database by editing the cells in JTable
Problem in Seperating Core Servlet to Database Query Java
SQL Server - Connection pool leak
Connection Pooling samples