In JDK 1.4, when a you wanted to retrive data from a database into a ResultSet, you should always leave the Connection opend till you mainpluate the data in the ResultSet, if you closed the Connection, data in the ResultSet are gone.
So, in 1.4 the following code is not okay:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(url, name, pass);
Statement stmt = c.createStatement();
ResultSet rs = s.executeQuery ( query );
con.close() // Closing connection b4 using rs is not okay
while (rs.next()) {
//.....
}
Java 5 solution
Java 5 has come with soem new exciting features, among these feature is the new JDBC APIs: CachedRowSet
A CachedRowSet object is a container for rows of data that caches its rows in memory, which makes it possible to operate without always being connected to its data source. Further, it is a JavaBeansTM component and is scrollable, updatable, and serializable. A CachedRowSet object typically contains rows from a result set, but it can also contain rows from any file with a tabular format, such as a spread sheet. The reference implementation supports getting data only from a ResultSet object, but developers can extend the SyncProvider implementations to provide access to other tabular data sources.
An application can modify the data in a CachedRowSet object, and those modifications can then be propagated back to the source of the data.
At this release, as an aid to developers, the RowSet interface has been implemented (as JSR 114) in five of the more common ways a RowSet object can be used. These implementations provide a standard that developers are free to use as is or to extend.
Following are the five standard implementations:
JdbcRowSet- used to encapsulate a result set or a driver that is implemented to use JDBC technology
CachedRowSet- disconnects from its data source and operates independently except when it is getting data from the data source or writing modified data back to the data source. This makes it a lightweight container
for as much data as it can store in memory.
FilteredRowSet- extendsCachedRowSetand is used to get a subset of data
JoinRowSet- extendsCachedRowSetand is used to get an SQLJOINof data from multipleRowSetobjects
WebRowSet- extendsCachedRowSetand is used for XML data. It describes tabular components in XML using a standardized XML schema.
Read More here:
http://java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/






I am a little bit confused!
Re: I am a littel bit confused!
Still confused! Because
Well, I have checked that
Here are my sources