Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why getXXX methods of Resultset require connection open?

 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Sunesh Kumar
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic