Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about java.sql.ResultSet

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
regarding java.sql.ResultSet,

1. it is an interface, then which class implements this interface ?

2. ResultSet contains db connections ? or for each move, it will connect to DB again ? or table rows are cached in memory, so it will not need DB connection ?

Thanks.
 
Jan Cumps
Bartender
Posts: 2608
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. it is an interface, then which class implements this interface ?
One of the classes that is residing in the jdbc jar.
It is a nice mechanism where you can write code using a database independent interface, and the database dependent class is loaded for you. When you step through the code with a debugger, you can see the real class that implements the interface.



ResultSet contains db connections ? or for each move, it will connect to DB again ? or table rows are cached in memory, so it will not need DB connection ?
It uses the connection. You can think about a ResultSet as a pointer (or cursor) into your query results. Each move will make it point to the next record.
The fact that it cashes records or not is dependent on the particular driver you use, and might be influenced by the value you set with setFetchSize().
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it does need a connection, as if you close the connection before processing the rows it throws an exception.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
or table rows are cached in memory, so it will not need DB connection ?


For this purpose , (that is Results to be cached in Memory) , you need to use CachedRowSet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic