CachedRowSet or SQL, what is the best way?

2001-09-05 Thread Ryan Cornia

Is anyone using the early access of CachedRowSet for data access, or are people just 
using straight JDBC calls?

I've been using straight JDBC calls, but it looks like CachedRowSet would be easier. 
Anyone know when it will be officially released? Is it currently stable?

Thanks,
Ryan





RE: CachedRowSet or SQL, what is the best way?

2001-09-05 Thread Justin Brister

Ryan,

I have been using the CachedRowSet and have not encountered any problems
with it to date. I too would be interested to know when a release of the
source code for these classes will be available.

Regards, Jay


-Original Message-
From: Ryan Cornia [mailto:[EMAIL PROTECTED]]
Sent: 05 September 2001 15:07
To: [EMAIL PROTECTED]
Subject: CachedRowSet or SQL, what is the best way?


Is anyone using the early access of CachedRowSet for data access, or are
people just using straight JDBC calls?

I've been using straight JDBC calls, but it looks like CachedRowSet
would be easier. Anyone know when it will be officially released? Is it
currently stable?

Thanks,
Ryan





Re: CachedRowSet or SQL, what is the best way?

2001-09-05 Thread Gregor Rayman

Ryan Cornia [EMAIL PROTECTED] asks:



 Is anyone using the early access of CachedRowSet 
 for data access, or are people just using straight 
 JDBC calls?
 
 I've been using straight JDBC calls, but it looks 
 like CachedRowSet would be easier. Anyone know when
 it will be officially released? Is it currently stable?

I use cached RowSets beacuse they hide the connections,
SQL and the whole persistence stuff from the JSP which
uses them.

I only had problems with some Oracle specialities (nested
ResultSets will not be serialized by the EarlyAccess 
version).

Other option would be to use the Rowset which opens a life
connection to the datasource. The Action would set up its
properties and the RowSet would fetsch the data when needed
in the JSP. The JSP has then to be responsible for closing
teh RowSet (I always call rs.close() in the JSP, even though
for the cached ones it is not necessary and it means I have 
to have scriplet in my JSP)

I'd prefer the second option if the caching becomes too heavy
burden for the memory. (Like a JSP which returns a table with
one million rows)

--
gR





Re: CachedRowSet or SQL, what is the best way?

2001-09-05 Thread Ted Husted

CachedRowSet seems fine for read-only accesses, but I'm told that
inserts and updates can be flakey (or impossible) with some drivers.

I have used RowSets extensively for accesses, and never had a problem.
The Jakarta TagLibs dbTag has also been recently extended so that you
can use read-only RowSets with their ResultSet tag (which has some nice
formatting features). 

Personally, I've gone back to ArrayLists and use a
BeanUtils.Populate-like method to quickly move the ResultSet into a
collection of beans. The nice thing here is that it's easier to extend
your own bean with custom accessors to format the property in various
ways, and provide other business logic hooks. Standardizing on
collections also makes it easier to move prototype code directly into
production, since they are easy to manufacture.

// Transfer ResultSet to Collection of target beans **
if (resultSet!=null) {
collection = ResultSetUtils.getCollection(
target,resultSet);
}

Where ResultSetUtils does this 

public static void populate(Object bean,
ResultSet resultSet)
throws SQLException {
// Build a list of relevant column properties from this
resultSet
HashMap properties = new HashMap();
// Acquire resultSet MetaData
ResultSetMetaData metaData = resultSet.getMetaData();
int cols = metaData.getColumnCount();
// Scroll to next record and pump into hashmap
if (resultSet.next()) for (int i=1; i=cols ; i++) {
// :TODO: Let native types through
/*
int type = metaData.getType(i);
if ...
properties.put(metaData.getColumnName(i),
resultSet.getObject(i));
else
*/
properties.put(metaData.getColumnName(i),
resultSet.getString(i));
}
// Set the corresponding properties of our bean
try {
BeanUtils.populate(bean, properties);
} catch (Exception e) {
throw new SQLException(BeanUtils.populate threw  +
e.toString());
}
}


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


Ryan Cornia wrote:
 
 Is anyone using the early access of CachedRowSet for data access, or are people just 
using straight JDBC calls?
 
 I've been using straight JDBC calls, but it looks like CachedRowSet would be easier. 
Anyone know when it will be officially released? Is it currently stable?
 
 Thanks,
 Ryan