This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes question about java.sql.ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "question about java.sql.ResultSet" Watch "question about java.sql.ResultSet" New topic
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel/download
 
subject: question about java.sql.ResultSet
 
Similar Threads
Scrolable ResultSet
recNo
why connection is a interface
get all records in GUI in B&S
Assigning values from resultset of db.