• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in JDBC

 
Shivakumar Mallikarjun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Presume that I have created a connection to DB, created Statement & execute the statement, result what I will get is ResultSet.
Immediately after this part, if I close the connection will I be able to retrieve the data from ResultSet?
[ September 16, 2005: Message edited by: Bear Bibeault ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. If you close a connection you discard the ResultSet. You will need to use a CachedRowSet or copy the data from the ResultSet into another Collection if you want to keep it in memory.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the continuation of paul's answer, every execution of query create a cursor, and this cursor can be either server side of client side depending on driver's implementation.

Your resultset does not hold any record once query is executed it points to the cursor created and moves to next or previous row on calling resultset.next() or resultset .previous() once you close the connection resultset will loose link to cursor and you will not be able to fetch data from resultset.

Shailesh
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65124
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Shivakumar M J Shivakumar M J",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious. Weird permutations like repeating your name twice are not allowed.

Thanks!
bear
Forum Bartender
 
Shivakumar Mallikarjun
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul & Shailesh for your valuable replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic