?
Solved

Passing a Reference to the Current row of a ResultSet

Posted on 2003-02-25
2
Medium Priority
?
227 Views
Last Modified: 2010-03-31
Is it possible ( and safe ) to pass a reference to the current row of a result set to a method
ie are the following snippets equivalent?

Snippet A
   while (rs.next())
   {
       System.out.println(rs.getString("cola")};
   }


Snippet B.
   while (rs.next())
   {
       methodA(rs);
   }

   private void methodA(ResultSet rs)
   (
      System.out.println(rs.getString("cola"));
   }


Thanks in advance

Dave
0
Comment
Question by:howesd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
yongsing earned 200 total points
ID: 8015473
They basically work the same. You are just passing the reference to the ResultSet to another method, and inside that method you invoked the getString() method. There is really no difference. The state of the rs object is not changed as a result of using methodA.
0
 
LVL 1

Author Comment

by:howesd
ID: 8015591
Thanks for that - my code was working OK, I just wanted to make sure that it was doing what I thought it should


Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question