Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Resultset question

 
Kajol Singh
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Fyodor Dostal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic