aspose file tools*
The moose likes JDBC and the fly likes NEED FOR CONNECTION OBJECT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
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://aspose.com/file-tools
 
subject: NEED FOR CONNECTION OBJECT
 
Similar Threads
servlet sendRedirect()
ResultSet and connection
open Resultset and closed connection
to store the form data temporarily at client side
ResultSet Query