aspose file tools
The moose likes JDBC and the fly likes NEED FOR CONNECTION OBJECT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "NEED FOR CONNECTION OBJECT" Watch "NEED FOR CONNECTION OBJECT" New topic
Author

NEED FOR CONNECTION OBJECT

Balaguru Krish
Greenhorn

Joined: Sep 23, 2005
Posts: 9
For iterating a resultset , why there is a need for a connection object after the resultset is being returned by executeQuery(sqlQuery) ?

ResultSet rs = stmt.executeQuery("select * from emp");
con.close();
while( rs.next() )
{

}

It throws an Exception .
Why?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

For your information, writing completely in capital letters is 'shouting' and is often considered rude.

ResultSets do not read all of the results from the query, and they need the Connection so that they are able to go back and read more results when required.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: NEED FOR CONNECTION OBJECT
 
Similar Threads
servlet sendRedirect()
open Resultset and closed connection
to store the form data temporarily at client side
ResultSet Query
ResultSet and connection