Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NEED FOR CONNECTION OBJECT

 
Balaguru Krish
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic