| Author |
question about java.sql.ResultSet
|
Edward Chen
Ranch Hand
Joined: Dec 23, 2003
Posts: 758
|
|
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
Joined: Dec 20, 2006
Posts: 2343
|
|
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().
|
OCUP UML fundamental
ITIL foundation
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
|
it does need a connection, as if you close the connection before processing the rows it throws an exception.
|
 |
Ravi Kiran Va
Ranch Hand
Joined: Apr 18, 2009
Posts: 2234
|
|
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.
|
Save India From Corruption - Anna Hazare.
|
 |
 |
|
|
subject: question about java.sql.ResultSet
|
|
|