| Author |
why getXXX methods of Resultset require connection open?
|
Kartik Patel
Ranch Hand
Joined: Sep 12, 2005
Posts: 73
|
|
Can Anyone please tell me why getXXX methods of java.sql.resultset requires Connection to be open? Is it going to the datbase each time when there is a getXXX call. Can anyone give me the official reference link of my understanding? Please reply with the reliable URL .
|
Chop your own wood, and it will warm you twice. - Henry Ford
|
 |
Chetan Parekh
Ranch Hand
Joined: Sep 16, 2004
Posts: 3636
|
|
Kartikbhai! Yes, if you want to do rs.getXXXX() you need connection to be open. Connection is basically a bridge between your Java Code and Database, and Resultset it just a vehicle running on a bridge. If you want to get any goods (read value) using vehicle (read Resultset) you need a bring (read connection) that connect one end to another end(read Java Code to Database). Are you clear now?
|
My blood is tested +ve for Java.
|
 |
Sunesh Kumar
Ranch Hand
Joined: Oct 17, 2005
Posts: 89
|
|
Hi Chetan Bhai, any mistakes please excuse... If we use the concept of Cached RowSet we can able to eliminate the concept of going the rs.getXXX every time to the database... Bye
|
Thanks & Regards<br />Sunesh Kumar Baachu
|
 |
Stan James
(instanceof Sidekick)
Ranch Hand
Joined: Jan 29, 2003
Posts: 8791
|
|
The normal result set can be lazy about retrieving rows from the db server. If you do a query that returns a million rows the result set might hold only a 1000 until you do next() to row 1001. This makes things easier on the network between the db and the java container and on Java memory. I suppose it makes more work for the database holding data longer until Java asks for it. You can break this by going to the last row immediately or by using certain cursors. Somebody more conversant with the details may chime in with more ways.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: why getXXX methods of Resultset require connection open?
|
|
|