Pramod-san wrote:

> <DIV><FONT face=Arial size=2>Hi all,</FONT></DIV>

HTML off please.

> Does any one know about any good Java OO implmentations using which
> direct database access from the middle layer can be avoided to the
> maximum ?
> 
> A vague explanation will be like - Middle layer coders will not be
> accessing database directly,  what they do is, create objects and
> [...]

I think I understand what you want.  You want to allow users to access the
database in a read-only fassion.  Would something like giving a been the
table name as a parameter and getting a 2D hash of "SELECT * from {0}"
where "{0}" is the passed table name do?

I've written such classes before, but with further restrictions and very
much tied to a particular application.  I wish they were more portable.

> Sorry if its stupid/confusing. Even I dont have a clear idea on that.
> If u get what i mean, please help

Not stupid at all.  Perhaps just redefining the problem would make it
easier to come up with a solution to build yourself.

Other than the table name, what kind of restrictions do you want to place
on the SELECT statement?  For example, I wouldn't allow subqueries as
strings since it would put other sensitive data at risk.  Conditions were
another passed parameter, and had to be checked to make sure that no
subqueries were in there.  Pass a list of fields (comma seperated or as an
array) to get things like "SUM(n) as N" (again, checking for subqueries).

After getting "SELECT *", the bean can then process what all of the field
names are using the ResultSetMetaData.  Types can be retrieved from the
meta data as well, if you want to support more types than just Strings.

Now, am I being too vague?  I don't know of such a package, but these are
a few ideas of how to implement one.  (I'm not sure that this relates to
Struts, though.)

Well, hope that helps to get you on the right track.

--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home:           http://www.seaple.icc.ne.jp/~westbay
Commentary:     http://www.japanesebaseball.com/

Reply via email to