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

Result Sets and Closing Connections

 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you normally retrieve your recordset, close your connection and still get your data from the record set? Just curious. Is this normal for all connections?
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dale DeMott:
Can you normally retrieve your recordset, close your connection and still get your data from the record set? Just curious. Is this normal for all connections?

negative on that one. Connection.close() calls the close methods on all associated statements which in turn calls the close() method on any resultsets associated with the statement.
The result is a closed resultset when you close it's underlying connection.
To avoid this, save your resultset to an arraylist or other Collection, then close the connection and resultset and use the collection.
Jamie
 
Dale DeMott
Ranch Hand
Posts: 515
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! Great explanation!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic