File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Disconnected resultsets... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Disconnected resultsets..." Watch "Disconnected resultsets..." New topic
Author

Disconnected resultsets...

D James Scanlan
Greenhorn

Joined: Jan 05, 2006
Posts: 6
Hello Everyone,

I come from a .net world. One of the nice objects within its data access architecture is a "DataTable". This is similar to a resultset but with one significant difference - it is completely disconnected from its datasource. Which, unless I'm missing the point, is different to resultsets in that they hold connections until they are destroyed.

I like writing generic data layers in whatever language I'm using and am seeking to write a generic method that calls a stored procedure that will return multiple rows. I want then to pass this data to other areas of my application. It doesn't look like I can use a resultset as that would leave open connections all over the place.

I know I could write a method that fills a resultset and then populates classes with the contents of this data but this is not generic.

I've already written a class called (drum roll) "DataTable" which converts a resultset to xml which is generic but feels expensive in terms of resources.

Am I venturing down a cul-de-sac of bad practice? If so, what should I be doing?


When not confused, asleep
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Hi Scanlan,

Welcome to Java world, and welcome to Java ranch as well.


One of the nice objects within its data access architecture is a "DataTable".


We do have similar object in java and that is CachedRowSet. You can use the same.



it is completely disconnected from its datasource. Which, unless I'm missing the point, is different to resultsets in that they hold connections until they are destroyed.


CachedRowSet are also disconnected from database, you can release you resultset once you populate your CachedRowSet. Onwards you can use it the way you like to do the programming.


Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
 
jQuery in Action, 2nd edition
 
subject: Disconnected resultsets...
 
Similar Threads
How to write a generic table model for resultset access ?
Solving for Page With Slow Response Time
Regular query vs JDBC Programming?
closing connections
Generic Value Object for data returned by Multiple resultsets