Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Resultset Problem!! need help asap


Message #1 by "Seema Patel" <spatel@e...> on Wed, 15 Jan 2003 14:11:03
Yes, 
 
It's possible to execute multiple queries (Whether it is a good idea or not, is
another discussion). As long as u don't close the Statement-and Connection-objects.
 
I have however had a problem ones with a driver for MS SQL Server, where I could
only create one ResultSet with a Statement, so if I wanted to use multiple ResultSets
I had to create multiple Statements.
 
Normally it would be like this.
 
stmt = conn.createStatement();
ResultSet rs1 = stmt.executeQuery(...);
ResultSet rs2 = stmt.executeQuery(...);
...
rs2.close();
rs1.close();
stmt.close();
 
But I do as well recommend not to have to many ResultSets open.
On the other hand putting all the information from a ResultSet into 
a Collection, to keep the Information not keeping the ResultSet open.
Is only recommended in case of small ResultSets.
In case of big ResultSets it would use to much Memory.
 
A ResultSet is just going to get the Row it wants into memory while
keeping the others on the database.
 
Greetings,
 
Bart Laeremans
 
 

	-----Oorspronkelijk bericht----- 
	Van: Catalin Ignat [mailto:cignat@s...] 
	Verzonden: wo 15/01/2003 15:37 
	Aan: Pro_JavaServer_Pages 
	CC: 
	Onderwerp: [pro_jsp] Re: Resultset Problem!! need help asap
	
	

	Hello,
	
	Even if involve a little bit of work at the beginning, you should use a bean
	class for accesing the database, this approach surely shows it's benefits in
	time.
	
	As for the recordsets, you should use them only inside the bean class, and
	return to the jsp page some kind of array or map, depending on your needs.
	In this way you can use this objects in any way you want.
	
	As for the scrolling forward or backward trough recordset rows, this depends
	on the recordset type, which can be set when opening the connection
	database. Most common does not accept moving backward, so using arrays or
	map objects as recordsets results again show it's advantages.
	
	HTH,
	Catalin
	
	
	----- Original Message -----
	From: "Seema Patel" <spatel@e...>
	To: "Pro_JavaServer_Pages" <pro_jsp@p...>
	Sent: Wednesday, January 15, 2003 2:11 PM
	Subject: [pro_jsp] Resultset Problem!! need help asap
	
	
	> Hi,
	>
	> is it possible to use 2-3 resultSets on a single jsp page where each of
	> the resultSets are linked to different SQL queries and are given different
	> names?; because at the moment the object ResultSet on the jsp page has
	> been defined once and im using rs  (alias for the ResultSet) 3 times in
	> the single jsp page and it works provided i call up the different methods
	> in the correct place on the code.  But i want to be able to refer back to
	> the differnt ResultSets on that page, which may be defined at the top page
	> and im calling it from the bottom of the page and there are 2 other
	> methods in the middle.
	>
	> seema
	
	
	



  Return to Index