Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can ResultSets be passed between methods of a class? Are there any special usage considerations?

0
10 Posted

Can ResultSets be passed between methods of a class? Are there any special usage considerations?

0
10

Location: http://www.jguru.com/faq/view.jsp?EID=245663 Created: Nov 5, 2000 Modified: 2000-11-20 21:48:12.454 Author: Ryan Breidenbach (http://www.jguru.com/guru/viewbio.jsp?EID=45212) Question originally posed by Daniel Yawitz (http://www.jguru.com/guru/viewbio.jsp?EID=241695 Yes. There is no reason that a ResultSet can’t be used as a method parameter just like any other object reference. You must ensure that access to the ResultSet is synchronized. This should not be a problem is the ResultSet is a method variable passed as a method parameter – the ResultSet will have method scope and multi-thread access would not be an issue. Aa an example, say you have several methods that obtain a ResultSet from the same table(s) and same columns, but use different queries. If you want these ResultSets to be processed the same way, you would have another method for that. This could look something like: public List getStudentsByLastName(String lastName) { ResultSet rs = … (JDBC code to retrieve s

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123