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 EJB and other Java EE Technologies and the fly likes Resultset question 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 » Java » EJB and other Java EE Technologies
Bookmark "Resultset question" Watch "Resultset question" New topic
Author

Resultset question

Kajol Singh
Greenhorn

Joined: Jul 22, 2002
Posts: 15
Hello,
Is it possible to pass a resultset from one method to another method.
example:
public static void main(String[] args)
{
ResultSet rs = getResultSet(sql);
}
public Resultset getResultSet(String sql){
PreparedStatement stmt = Conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
return rs;
}
Thanks,
Kaj


Kaj
Fyodor Dostal
Greenhorn

Joined: Aug 24, 2002
Posts: 2
yes
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Originally posted by Kajol Singh:
Hello,
Is it possible to pass a resultset from one method to another method.
example:
public static void main(String[] args)
{
ResultSet rs = getResultSet(sql);
}
public Resultset getResultSet(String sql){
PreparedStatement stmt = Conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
return rs;
}
Thanks,
Kaj


It is possible unless you are working in a distributed environment (cannot use a ResultSet as a return type or parameter type in RMI). What you are doing should work perfectly fine. Using a helper method to create the result set is okay.


James Carman, President<br />Carman Consulting, Inc.
 
 
subject: Resultset question
 
Similar Threads
Using a Bean for Retrieving Results Sets - Best Approach
Need assistance with approach to problem
Statement Closed Error - please help
Close a resultset in a function while returning the values
Resultset is closed