This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
ResultSet and connection
ResultSet Query
to store the form data temporarily at client side
servlet sendRedirect()
open Resultset and closed connection