File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resultset question