The two typical solutions are disconnected RowSets and copying the ResultSet into a collection of value objects. Pros and cons abound for either method - one pollutes your code with sql packages and one involves copying a lot of data...
-- Voytek Jarnot Quidquid latine dictum sit, altum viditur. > -----Original Message----- > From: Kirby Vandivort [mailto:[EMAIL PROTECTED] > Sent: Wednesday, February 26, 2003 11:59 AM > To: [EMAIL PROTECTED] > Subject: [OT] database access philosophy > > > Hello, > > I'm in the process of converting an old webapp over to using struts > and, in the process, I decide to clean up the database access. > > Old Way: > I had written a connection pool and instantiated an instance of this > that was passed to all methods that needed the db, and they they had > the sql code embedded in the methods. > > New Way that I'm working on: > I've set up a DataSource for my jdbc connection, and I'm partitioning > off all of the database access code into it's own package. If my > business logic needs database info, it calls a method from > the database > access package to get it. > > My problem: > > Many methods from the database access return simple data. > > However, I currently have it written so that some of the more complex > ones return a ResultSet, which I'm not really happy with. > This exposes > the DB layer to the business logic, but I'm not totally sure what the > best way to avoid this is. In addition, this doesn't work :( because > the underlying connection gets closed when the database access method > exists, and the ResultSet is no longer valid. > > SO, I am wondering what people do when they need to return all of the > data in a ResultSet to their business layer. Do you have to go to the > hassle of copying everything to some sort of data structure, or is > there a better, cleaner, faster way to handle this? > > (I'm kind of assuming that the ResultSet will be small enough to fit > in memory and there won't be issues with pulling it in in pieces; how > would that be handled, though?) > > Thanks, > > -- > > Kirby Vandivort Theoretical and > Computational Biophysics > Email: [EMAIL PROTECTED] 3051 Beckman Institute > http://www.ks.uiuc.edu/~kvandivo/ University of Illinois > Phone: (217) 244-5711 405 N. Mathews Ave > Fax : (217) 244-6078 Urbana, IL 61801, USA > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]